The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: hila123 on June 24, 2005, 11:29:20 PM

Title: EnableMenuItem problem ...
Post by: hila123 on June 24, 2005, 11:29:20 PM
hi,

i have problem when using EnableMenuItem....
i have 2 menu items (Pause and Resume) and it's not a popup menu

what i wanted to achive is when i select the pause menu the resume menu will be grayed out and vice versa
the problem is when i pressed the pause menu and set resume menu to gray but the resume menu will not show grayed right after i set it to gray..
it will only appear gray when i move my mouse over it or the dialog box get overlapped by another window....

here is my code

mov eax,wParam

.if eax==IDM_PAUSE
  invoke EnableMenuItem,hMenu,IDM_PAUSE,MF_GRAYED
  invoke EnableMenuItem,hMenu,IDM_RESUME,MF_ENABLED
.elseif eax==IDM_RESUME
  invoke EnableMenuItem,hMenu,IDM_PAUSE,MF_ENABLED
  invoke EnableMenuItem,hMenu,IDM_RESUME,MF_GRAYED

any advice is welcome :)
Title: Re: EnableMenuItem problem ...
Post by: Mark Jones on June 25, 2005, 05:16:27 AM
Hila, I'm not positive but I think what you could do is forcel the window to redraw. Try this:

.if eax==IDM_PAUSE
  invoke EnableMenuItem,hMenu,IDM_PAUSE,MF_GRAYED
  invoke EnableMenuItem,hMenu,IDM_RESUME,MF_ENABLED
  invoke SendMessage,hWnd,WM_PAINT,hDC,0
.elseif eax==IDM_RESUME
  invoke EnableMenuItem,hMenu,IDM_PAUSE,MF_ENABLED
  invoke EnableMenuItem,hMenu,IDM_RESUME,MF_GRAYED
  invoke SendMessage,hWnd,WM_PAINT,hDC,0

where hDC is the handle of the device context if used, otherwise try a 0.
Title: Re: EnableMenuItem problem ...
Post by: donkey on June 25, 2005, 05:21:46 AM
You might try DrawMenuBar instead, it will redraw the menu for the specified window...

invoke DrawMenuBar, [hWnd]
Title: Re: EnableMenuItem problem ...
Post by: hila123 on June 25, 2005, 05:29:14 AM
thanks Mark Jones and donkey reply...  :bg

@donkey
ur method worked... :U
Title: Re: EnableMenuItem problem ...
Post by: Bros on January 02, 2007, 05:04:25 PM
Hello

I have the same problem but I activate a menu when I clicked in a child windows...

How can I do a invoke DrawMenuBar, [hWnd] in the child windows to refresh the Menu in the main window?

Thanks