#### Archived

This topic is now archived and is closed to further replies.

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

## Recommended Posts

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

##### Share on other sites
Look at where he registers the window class, it specifies the menu to be used.

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.

##### Share on other sites
ok, now i have the file menu, but i cant see the submenu which i created.

www.web-discovery.net

##### Share on other sites
here is a part of my CreateGLWindow function:

wc.lpszClassName= "OpenGL"; // Set The Class Name

as you can see now i have a menu name. If i run the following instruction

i get an access violation !

www.web-discovery.net

##### Share on other sites

HINSTANCE hInstance, // handle of application instance
);

HWND hWnd, // handle of window
);

);

Crispy

##### Share on other sites
... and where do i define hmenu, the handle to the menu ?

www.web-discovery.net

##### Share on other sites

IDC_MENU has been defined in the resource.rc file, so i have a simple menu. When i run the app, i get the File header but no sub-menus.

www.web-discovery.net

##### Share on other sites
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

##### Share on other sites
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 !

www.web-discovery.net

##### Share on other sites
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