James
James

Reputation: 1852

Dynamic menus in MFC

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

Upvotes: 0

Views: 1624

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308176

If you're calling GetMenu from within a window class derived from CWnd, you'll be calling CWnd::GetMenu and 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 its m_hWnd member or by calling GetSafeHwnd() on it.

Upvotes: 1

Related Questions