Solved

check/uncheck a menu item

Posted on 2001-06-30
2
560 Views
Last Modified: 2013-11-20
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.



0
Comment
Question by:kung
2 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6241164
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


0
 
LVL 12

Accepted Solution

by:
migel earned 300 total points
ID: 6241170
Hi!
1. open wizard dialog (Ctrl+W)
2. select your frame class in the second combobox.
 select in the left list ID_CONNECTIONS.
Double click in the right list on the UPDATE_COMMAND_UI item
3.Press OK in the appeared dialog.
4. double click on the added item in the bottom list.
5. In the editor window:
void CMainFrame::OnConnectionsUpdate(CCmdUI* pCmdUI)
{
    pCmdUI->SetCheck(bCheck); // this code sets or remove check in the menu depending on bCheck value
}


0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 92
maven archtype selection in eclipse 1 57
modThree challenge 4 89
Updating statistics with error notification email in SQL server 4 94
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now