Hi, in my project resource.rc file i create a valid IDC_MENU. How do i reference it in the CreateGLWindow function of nehe''s code ?
www.web-discovery.net
Look at where he registers the window class, it specifies the menu to be used.
wc.lpszMenuName = MAKEINTRESOURCE(IDC_MENU);
Remember though, the menu takes up about 10 pixels or so, and covers up the top of the Open GL window. You will need to compensate for this or just leave it be. Perhaps a better solution would be to make the menu show up when the user hits a key and then when the user clicks on the window again, it hides it.
HMENU LoadMenu( HINSTANCE hInstance, // handle of application instance LPCTSTR lpMenuName // menu name string or menu-resource identifier );
Create the window and then call LoadMenu() and the SetMenu():
BOOL SetMenu( HWND hWnd, // handle of window HMENU hMenu // handle of menu );
Whne you''re done, call DestroyMenu():
BOOL DestroyMenu(
HMENU hMenu // handle to menu to destroy );
and SetMenu(hWnd, NULL); to unbind any bound menus from the window.
Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Why are you loading two different menus? The reason I gave you the function prototypes was to spare you the time of looking them up - of course they have been declared and defined internally by WinAPI.
Are you storing the menu name/ID as a string or DWORD (a numeric constant) in the resource file. That is - does the name have quotes around it or not? If it does, you don''t need to call MAKEINTRESOURCE(). Additionally, set the WindowClass.lpszMenuName member to NULL when you create the window.
And finally - what do you mean by "submenus"? A submenu is an expanding list of menuitems that can be activated by moving the mouse cursor or caret over a menu item that traditionally has an arrow next to it: such as View->Toolbars in Internet Explorer.
Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
The problem is that i have the menu correctly displayed, but when i click on it, i dont get the submenus defined with a AppendMenu statement. Also, when i click on the minimize or maximize or close box of the window, nothing happens. Why C++ has to be this damn difficult !
It seems to me you''re using AppendMenu() incorrectly - remember - you have to reference the parent menu in order for some other menu to become a submenu. Here''s an example:
MENUITEMINFO MenuItem;MenuItem.cbSize = sizeof(MENUITEMINFO);MenuItem.fMask = MIIM_TYPE | MIIM_SUBMENU | MIIM_CHECKMARKS;MenuItem.fType = MFT_STRING;MenuItem.fState = MFS_ENABLED;MenuItem.wID = NULL;MenuItem.hbmpChecked = NULL;MenuItem.hbmpUnchecked = NULL;MenuItem.dwItemData = NULL;MenuItem.dwItemData = NULL;MenuItem.hSubMenu = ThisItemsSubMenu; //a 2nd level submenu that expands from this item; this item belongs to a 1st level submenuMenuItem.cch = SomeString;MenuItem.dwTypeData = (char *)malloc(SomeString.length());strcpy(MenuItem.dwTypeData, SomeString.c_str());InsertMenuItem(SubMenu, GetMenuItemCount(Menu), MF_BYPOSITION, &MenuItem); //let''s recap: "Menu" is the root menu, "SubMenu" is the menu//into which you''re inserting (the 1st level submenu in this //case) and "MenuItem" is the item that you''re instering that will //be the root item for a 2nd level submenu
It doesn''t use AppendMenu(), but the idea is the same.
Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared