Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

check/uncheck a menu item

Posted on 2001-06-30
2
Medium Priority
?
565 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 900 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
In this post we will learn different types of Android Layout and some basics of an Android App.
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

715 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