Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Checking menu item in context menu

Posted on 1998-08-13
3
Medium Priority
?
205 Views
Last Modified: 2013-11-20
Hi guys,

in my program I create a context menu containing two sub menus. When I select a menu item from one of the sub menus I want it to be checked. So I used the OnUpdate... function to check the item with  pCmdUI->SetCheck(1);  When debugging the program the function is called, the ID is correct and everything seems to be fine. But when I want to select the item again, it isn´t checked. Can somebody help me ??

Thanks in advance

Nick
0
Comment
Question by:nl1545
3 Comments
 

Expert Comment

by:t004024
ID: 1320724
When handling the WM_CONTEXTMENU how are U displaying the context menu? If U are loading/creating the menu everytime, then U have to do the explicitly setting of check depending on whether U had it previously selected or not.

0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 total points
ID: 1320725
I suspect you are reloading the menu from the resource file each time ?

EITHER
Save the state in a variable (e.g. add a boolean to the class), and then whenever you setup the menu, set the initial checked/unchecked state depending on the value in this variable.

OR
Load the menu once (e.g. in your constructor) and simply redisplay it each time.

Personally I prefer the first solution, as you can write one function ("PrepareMenu") and keep all the menu state logic in once place.  This is useful if you later add more check options, default options or radio options to the menu.

0
 

Author Comment

by:nl1545
ID: 1320726
Thank you,

I thought the COMMAND_UPDATE_UI handler would be called BEFORE the menu is displayed for the first time (as it is with normal items)
But your hint does solve my problem, too

Nick
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

824 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