I need to create some dynamic menus in a VS2010 SDI application I’m writing. I’ve seen this, but don’t really understand it
Dynamic menu using mfc
At the moment, I’ve no idea how to even use GetMenu to get a handle to the menu from my Doc file. I’m trying this, but it says GetMenu doesn’t take zero arguments, even though many examples I’ve seen clearly show this.
CMenu *menu = GetMenu();
menu->AppendMenu(MF_STRING, ID_HIDE, _T("Text"));
All I want to do is add a list of files underneath a sub-menu, selected from a database (hence the dynamic part), so a user can select the one they want to work on.
Thanks,
James
If you’re calling
GetMenufrom within a window class derived fromCWnd, you’ll be callingCWnd::GetMenuand it will not require a window handle. If you’re calling it from anywhere else you will get::GetMenu(HWND)and you will need to pass a window handle. You can get the handle from any CWnd object with itsm_hWndmember or by callingGetSafeHwnd()on it.