NO

Author Topic: How to disable menu item in Dialog?  (Read 878 times)

Offline bitcoin

  • Member
  • *
  • Posts: 106
How to disable menu item in Dialog?
« 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
  }
}




Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1896
Re: How to disable menu item in Dialog?
« Reply #1 on: July 22, 2019, 04:06:49 pm »
EnableMenuItem() should work.
Code: [Select]
HMENU hMenu = GetMenu(hwnd);
EnableMenuItem(hMenu, 6002, MF_DISABLED);
May the source be with you

Offline bitcoin

  • Member
  • *
  • Posts: 106
Re: How to disable menu item in Dialog?
« Reply #2 on: July 22, 2019, 11:13:53 pm »
Yes, it works, thnx. I don't know about GetMenu function..