Link to home
Start Free TrialLog in
Avatar of kung
kung

asked on

check/uncheck a menu item

I am using Visual C++ 6.0
I have made a "hello world" program via the wizard
I have added a menu item to the window
with the name ID_CONNECTIONS

My question is

I want, when the user select the menu item, check and uncheck the menu item with the name ID_CONNECTIONS.

What source code should I add to the project created by
the wizard so this happends.



Avatar of jkr
jkr
Flag of Germany image

You can achieve that using 'CMenu::CheckMenuItem()'

You'll have to obtain the meu handle for your window first:

CMenu *pmenu = AfxGetMainWnd()->GetMenu();

pmenu->CheckMenuItem ( ID_CONNECTIONS, MF_BYCOMMAND | MF_CHECKED); // to check the item

pmenu->CheckMenuItem ( ID_CONNECTIONS, MF_BYCOMMAND | MF_UNCHECKED); // to uncheck the item


ASKER CERTIFIED SOLUTION
Avatar of migel
migel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial