Public Group

# On a completly different subject (WIN32 API)

This topic is 4807 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

For reasons that will take too long to explain, I am editing my resource.h and resource.rc file by hand. I pretty much understand how to do basic menu stuff. I want to make a File menu that has a New option, with the slide out menu, sort of like in Internet Explorer. Where you click on File, then New, and it pops out the menu with window, message, etc. Does anyone know how to do that the way I am trying to do it? Also, the little check marks, like when you go to View, then Toolbars. It has a check next to the tool bars you have up. How do I make the check mark, and also how do I test to see if it is checked or set it to checked? I have looked over several WIN32 API tutorials, but none seem to have this info. Most assume you have visual c++ with the resource editor. I don't. Thanks again for any help or links to pages that could help.

##### Share on other sites
its been a while since i did any win32 stuff by hand, but would you do something like this:

MAINMENU MENU DISCARDABLE BEGIN    POPUP "&File"    BEGIN        POPUP "&New"        BEGIN            MENUITEM "New thing 1", NEW_THING1_ID            MENUITEM "New thing 2", NEW_THING2_ID            , CHECKED        END    ENDEND

as for the ticked, unticked thing, see above for how to make a menu item checked.
as for setting and reading the checked state in code, i'll have to get back to you on that.

aha.. here we go
case QMDVIEWERMENU_VIEW_TEXTURED:{    UINT wID = LOWORD(wParam);    HMENU hMenu = GetMenu(hWnd);	   if ( !this->textured )   {	glEnable(GL_TEXTURE_2D);	CheckMenuItem(hMenu, wID, MF_CHECKED);   }   else    {	glDisable(GL_TEXTURE_2D);	CheckMenuItem(hMenu, wID, MF_UNCHECKED);   }	this->textured = !this->textured;	return 0;}

this code, taken from a model 3d viewer i wrote, goes in your windows message proc function under WM_COMMAND. the case switch is the id of the menu item.

The above function has actually been superceded by SetMenuItemInfo(), so if you want to be current, you could lokk that up. Also check out GetMenuItemInfo(). Hope this helps.

##### Share on other sites
Once I saw your code for the sliding menu thing, I felt like such an idoiot. LOL. I was trying to create a new menu item, like this...

MAINMENU MENU DISCARDABLE BEGIN    POPUP "&File"    BEGIN//Next line is where I messed up        SECONDMENU MENU DISCARDABLE        BEGIN            MENUITEM "New thing 1", NEW_THING1_ID            MENUITEM "New thing 2", NEW_THING2_ID            , CHECKED        END    ENDEND

As far as the whole checked unchecked thing, I went to MSDN and searched for GetMenuItemInfo(). It took a little digging, but I got it working now. You need to put the following line in the WM_CREATE area for the dialog you are working for.

Where hmenuBar is of type HMENU. I declared hmenuBar as global. Then, in the WM_COMMAND of WND_PROC of the main window, you need the following code.

case ID_VIEW_TERRAIN://first, check to see if the item is checkedif(CheckMenuItem(hmenuBar,ID_VIEW_TERRAIN,MF_BYCOMMAND) == MF_UNCHECKED){//if not, check it. You can use MF_UNCHECKED instead to uncheck it, but this //code seems to work both ways	CheckMenuItem(hmenuBar,ID_VIEW_TERRAIN,MF_BYCOMMAND | MF_CHECKED);}					break;

Where ID_VIEW_TERRAIN is the id of a menu item.

Thanks so much for your help on this!

• 15
• 9
• 13
• 41
• 15