News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

EnableMenuItem problem ...

Started by hila123, June 24, 2005, 11:29:20 PM

Previous topic - Next topic

hila123

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 :)

Mark Jones

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.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

donkey

You might try DrawMenuBar instead, it will redraw the menu for the specified window...

invoke DrawMenuBar, [hWnd]
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hila123

thanks Mark Jones and donkey reply...  :bg

@donkey
ur method worked... :U

Bros

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