?
Solved

Checked Menu's In C++

Posted on 2003-02-20
10
Medium Priority
?
471 Views
Last Modified: 2008-02-01
Hey Guys,

     I am adding to a piece of a program right now and I am working on implementing a check menu. I am using this function:

DWORD CheckMenuItem(
  HMENU hmenu,        // handle to menu
  UINT uIDCheckItem,  // menu item to check or uncheck
  UINT uCheck         // menu item options
);

The problem is I want to be able to choose two or more options simultaneously (which I can already do) but I can't get the code to allow more than one option to be checked at one time.


                      Thanks A Lot,
                         misiti3780
0
Comment
Question by:misiti3780
[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
10 Comments
 
LVL 7

Expert Comment

by:webJose
ID: 7990319
As far as I know, the CheckMenuItem function does not uncheck a menu item if another one is checked.  Are you sure you are doing it ok?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7992456
To set checks on two different menu itesm, you need to call CheckMenuItem twice.  Pass in a different uIDCHeckItem value in each of the calls

Or is the problem that when you use the mouse to pull down a menu, you can not figure out how to make is stay down so that you can check or uncheck several items?  If that is the case, here is the info:  There is no way to do that because as soon as you select an item from a drop-down menu, it will automatically close the menu.   One just learns to live with that limitation.  If you need that kind of functionaluty, you should put a a dialog box that has the several checkboxes.

-- Dan
0
 

Author Comment

by:misiti3780
ID: 7994519
Dan, the second part of your question was not the problem, it was keeping two areas checked simultaneously.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 49

Expert Comment

by:DanRollins
ID: 7995699
If your second call to CheckSetMenu is causing a different menu item to be unchecked, then there is something wrong with your program code.  Please post the code that is exhibiting the problem.

-- Dan
0
 

Author Comment

by:misiti3780
ID: 8067077
here is the important part of my code
void
MessageHandeler::UpDateCheck(int wmId, HWND hWnd)
{
        HMENU activeMenu = NULL;
          activeMenu = GetMenu(hWnd);


             CheckMenuItem(activeMenu, ID_SELECT_ALL, MF_UNCHECKED);
         
        CheckMenuItem(activeMenu, ID_SELECT_TETS, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_WEDGES, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_PYRAMIDS, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_HEXS, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_TRIS, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_QUADS, MF_UNCHECKED);
        CheckMenuItem(activeMenu, wmId, MF_CHECKED);  
}


anymore questions just respond
0
 

Author Comment

by:misiti3780
ID: 8067145
here is the important part of my code
void
MessageHandeler::UpDateCheck(int wmId, HWND hWnd)
{
        HMENU activeMenu = NULL;
          activeMenu = GetMenu(hWnd);


             CheckMenuItem(activeMenu, ID_SELECT_ALL, MF_UNCHECKED);
         
        CheckMenuItem(activeMenu, ID_SELECT_TETS, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_WEDGES, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_PYRAMIDS, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_HEXS, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_TRIS, MF_UNCHECKED);
          CheckMenuItem(activeMenu, ID_SELECT_QUADS, MF_UNCHECKED);
        CheckMenuItem(activeMenu, wmId, MF_CHECKED);  
}


anymore questions just respond
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 8068431
your code is intentionally unchecking all of the items!  


     CheckMenuItem( ...., MF_UNCHECKED);

requests an item to be unchecked.  So that explains it!  Just remove all of those lines and you can then put checkmarks on any combination of them.  Here is an example:

void
MessageHandeler::UpDateCheck(int wmId, HWND hWnd)
{
    HMENU activeMenu= GetMenu(hWnd);
    CheckMenuItem( activeMenu, wmId, MF_CHECKED );  
}

-- Dan
0
 
LVL 2

Expert Comment

by:udil
ID: 8868884
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.

In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Udil
EE Cleanup Volunteer
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8872269
I object.  
I have answered the question, provided a good explanation, and I pointed out the problem with the Asker's code.  I should be awarded the points.

-- Dan
P.S.  Thanks for the efforts here, udil :-)
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 9355965
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Grade of A to Dan.



Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Ged
EE Cleanup Volunteer

PS:

Dan . . . It was just a wakeup ping.  He said he MAY recommend that it be deleted.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

764 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