Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 495
  • Last Modified:

Checked Menu's In C++

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
misiti3780
Asked:
misiti3780
1 Solution
 
webJoseCommented:
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
 
DanRollinsCommented:
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
 
misiti3780Author Commented:
Dan, the second part of your question was not the problem, it was keeping two areas checked simultaneously.

0
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.

 
DanRollinsCommented:
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
 
misiti3780Author Commented:
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
 
misiti3780Author Commented:
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
 
DanRollinsCommented:
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
 
udilCommented:
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
 
DanRollinsCommented:
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
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now