News:

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

checking menu items

Started by timertik, April 21, 2007, 09:19:47 AM

Previous topic - Next topic

zooba

Since the menu exists already, the return values of GetModuleHandle and LoadMenu are correct. My point was that the return value of LoadMenu must be kept somewhere. Alternatively, as Ramguru suggested, you get use GetMenu which will give the same value.

Quote from: ramguru on April 21, 2007, 11:40:48 AM
How about this
invoke GetMenu, hWin
invoke GetSubMenu, eax, x ; zero based File - 0, Settings - 1, Help - 2
invoke CheckMenuItem, eax, 9010, MF_BYCOMMAND+MF_CHECKED

There is no reason why this code wouldn't work, though if there is only one menu with the ID 9010 you can skip the GetSubMenu call, as MF_BYCOMMAND will search all sub menus as well (see Raymond Chen's blog). MF_BYCOMMAND is the default, so there's no problem leaving it out (or leaving it in).

The most likely problem now is that the menu is being loaded again to set the item check. While this will work, the item is indeed being checked, it's on a different menu to the one that's displayed. Store the value returned by the first LoadMenu (or use GetMenu) and pass that into CheckMenuItem.

Cheers,

Zooba :U

timertik

ramguru your code works perfect! very nice thanks , sorry I looked over it I was trying to fix the other code but yours works perfect!
I think the problem was the submenu using LoadMenu just declared the menu and not the submenu.