Pelles C forum

C language => Windows questions => Topic started by: bitcoin on July 22, 2019, 03:43:26 AM

Title: How to disable menu item in Dialog?
Post by: bitcoin on July 22, 2019, 03:43:26 AM
hello

I have dialog with menu. How to disable some menu item?

EnableMenuItem - don't works, probably this for usual windows.

EnableWindow(GetDlgItem(hwndDlg,MI_SOMEDATA),FALSE); - don't works, but no errors

EnableWindow(GetDlgItem(hwndDlg,MENU_ID),FALSE); - don't works, because unknown identifier (but in res file this exists).

In res:

Code: [Select]
MENU "MENU_ID"
..skipped..

MENU_ID MENUEX
{
  POPUP "&File", 0, 0, 0
  {
    MENUITEM "&Open", MI_OPEN, 0, 0
    MENUITEM "&Close", MI_CLOSE, 0, 0
    MENUITEM "", 0, 0|MFT_SEPARATOR, 0
    MENUITEM "&Exit", MI_EXIT, 0, 0
  }
  POPUP "&Edit", 0, 0, 0
  {
    MENUITEM "&SomeAct", MI_SOMEDATA, 0, 0
  }
}



Title: Re: How to disable menu item in Dialog?
Post by: TimoVJL on July 22, 2019, 04:06:49 PM
EnableMenuItem() should work.
Code: [Select]
HMENU hMenu = GetMenu(hwnd);
EnableMenuItem(hMenu, 6002, MF_DISABLED);
Title: Re: How to disable menu item in Dialog?
Post by: bitcoin on July 22, 2019, 11:13:53 PM
Yes, it works, thnx. I don't know about GetMenu function..