how can i check a menuitem with a V on the left of it, like so many apps do?
thank you.
how can i check a menuitem with a V on the left of it, like so many apps do?
thank you.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
For resources: MENUITEM Statement
For code: Menus
gg
it returns MF_UNCHECKED, but doesn't check the item, why is that?Code:CheckMenuItem(LoadMenu(ghInstance, MAKEINTRESOURCE(ID_MENU)), IDM_SETTINGS_GROUP, MF_CHECKED);
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Use GetMenu to get a handle to the window menu and GetSubMenu for any of that menu's submenus.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
this code now returns an error that the menuitem could not be found?Code:CheckMenuItem(GetMenu(hwnd), IDM_SETTINGS_GROUP, MF_CHECKED)
can you please explain the idea behind submenus, maybe i need to use them...
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Originally Posted by Devil PanterPlease read, in particular, the 'about menus' section and then take another look at the descriptions for CheckMenuItem, GetMenu and GetSubMenu.Originally Posted by Codeplug
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
I now understand what a position is but i still don't understand where i use it, or should i say how i use it...
i need a position of 3:2, which is the IDM_SETTINGS_GROUP.
can you please give me an example, because i'm really lost hereCode:CheckMenuItem(GetSubMenu(hwnd, 3), IDM_SETTINGS_GROUP, MF_BYPOSITION | MF_CHECKED);
Last edited by Devil Panther; 12-09-2004 at 08:54 AM.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
You're almost there but the first parameter of GetSubMenu is an HMENU.orCode:/*only works if IDM_SETTINGS_GROUP is the position of the menu item and NOT its id*/ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 3), IDM_SETTINGS_GROUP, MF_BYPOSITION | MF_CHECKED);Code:/*only works if IDM_SETTINGS_GROUP is the id of the menu item and NOT its position*/ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 3), IDM_SETTINGS_GROUP, MF_BYCOMMAND | MF_CHECKED);
Last edited by Ken Fitlike; 12-09-2004 at 01:44 PM. Reason: corrected typos spotted by Devil Panther (see folowing post)
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
the IDM_SETTINGS_GROUP is an idetifier of the menuitem...
i tried both ways, it still gives me an error that the menuitem could not be found.
btw, you meant:
andCode:/*only works if IDM_SETTINGS_GROUP is the position of the menu item and NOT its id*/ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 3), IDM_SETTINGS_GROUP, MF_BYPOSITION | MF_CHECKED);
Code:/*only works if IDM_SETTINGS_GROUP is the id of the menu item and NOT its position*/ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 3), IDM_SETTINGS_GROUP, MF_BYCOMMAND | MF_CHECKED);
Last edited by Devil Panther; 12-09-2004 at 09:52 AM.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
>>btw, you meant:<<
Thanks, yes I did. Sorry about that.
[edit]Fixed now.[/edit]
>>still gives me an error<<
Is your menu item a submenu item of a submenu item of a submenu item...etc? If so, you'll have to keep using GetSubMenu item in an analgous way to get a valid menu handle.
If not then it might be a good idea to post some more code.
Last edited by Ken Fitlike; 12-09-2004 at 01:44 PM.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
If i'm not mistaken i have a simple submenu item, but just in case:
http://thedp.netfirms.com/a.html
about posting more code, this is it, what else can i post everything else is not related.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Then this should work:assuming that IDM_SETTINGS_GROUP is the id for that particular menu item.Code:CheckMenuItem(GetSubMenu(GetMenu(hwnd), 3), IDM_SETTINGS_GROUP, MF_BYCOMMAND | MF_CHECKED);
Where in your code are you calling CheckMenuItem? WM_COMMAND handler? Is CheckMenuItem actually being called? Return value of CheckMenuItem?
>>what else can i post everything else is not related<<
If all else fails then create a window with the same menu and see if you can replicate the problem with that simplified, cut-down version. If you still encounter the same problem with the simplified test example then post the code for it.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
i thought so... it doesn't work
i'm calling the CheckMenuItem from WM_CREATE.
and it returns -1 --> menuitem not found.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Did you try this? Is this what "it doesn't work" is referring to? If so, post that code or zip up and attach it.If all else fails then create a window with the same menu and see if you can replicate the problem with that simplified, cut-down version.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
i tried something else:
i loaded the menu from the resource, and it returned a good value: MF_UNCHECKEDCode:CheckMenuItem(GetSubMenu(LoadMenu(ghInstance, MAKEINTRESOURCE(ID_MENU)), 3), IDM_SETTINGS_GROUP, MF_CHECKED)
but still nothing changed...
i guess i'll do what you said, and post a full code tomorrow.
thanks.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.