Sign in to follow this  
mrtie_dye

On a completly different subject (WIN32 API)

Recommended Posts

mrtie_dye    184
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 this post


Link to post
Share on other sites
JohnHurt    334
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
END
END





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 this post


Link to post
Share on other sites
mrtie_dye    184
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
END
END







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.

hmenuBar = GetMenu(hwnd);

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 checked
if(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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this