CheckMenuItem does not work...

Started by
2 comments, last by iMalc 20 years, 1 month ago
Hi. I am trying to make a menu where the item you last selected is checked. However none of my atempts at checking the menu item are working. GetMenuState even insists that my menus are checked when I tell them to, but alas no checkmark appears. I added a call to DrawMenuBar. I made sure that the menu item bitmaps were both NULL (which makes it use the default checkmark). However I also tried providing valid bitmaps but that made no chenge either. It will only tick the item if I make it checked in my memu resource. But then I can''t un-check it of course. The only thing I can think of is it might somehow be reloading the original menu resource each time after I try and change it, but I can''t see how it would be, and besides GetMenuState still reckons they''re checked. Please help, this is driving me nuts! MSVC++ 6, no MFC. Here''s a snippet of me trying to check all of the menu items in desperation: n = GetMenuItemCount(mnu); for (i=0; i<n; ++i) { CheckMenuItem(mnu, i, MF_BYPOSITION|MF_CHECKED); } DrawMenuBar(hWnd);
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Advertisement
How are you getting mnu? Are you getting the correct sub-menu?
.
HMENU mnu = LoadMenu (hInst, MAKEINTRESOURCE(IDC_MYMENU));
mnu = GetSubMenu (mnu, 1);

I know it is the correct menu, it''s the only one with 33 items in it.

btw It looks like this site''s fancy formatting screwed up the cpp code I posted and I don''t know how to make it format like C++ on this site.

Thanks for your reply.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
How does the window itself get the menu? Is it a window class menu or one provided at the time CreateWindow was called? Because you need to use the sub-menu of the menu that particular window is using. If it is a window class menu get the main menu with GetMenu then get the submenu from it. If you provided the menu in the CreateWindow call, then you already have the main menu handle, but could still use GetMenu to get it again if you tossed the handle into the bit bucket.
.

This topic is closed to new replies.

Advertisement