Solved

check/uncheck a menu item

Posted on 2001-06-30
2
557 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

15 Experts available now in Live!

Get 1:1 Help Now