Start New Discussion within our Software Development Community

The last few days I've been attempting to make a popup window with a menu outside of the WinMain class.

void CMFToolbar::GetQuote()
{

	InitCommonControls();

	if(m_pBrowser)
	{	
		WNDCLASSEX wc;
		HWND hwnd;
		MSG Msg;

		wc.cbSize		 = sizeof(WNDCLASSEX);
		wc.style		 = 0;
		wc.lpfnWndProc	 = (WNDPROC)WndProc;
		wc.cbClsExtra	 = 0;
		wc.cbWndExtra	 = 0;
		wc.hInstance	 = GetModuleHandle(NULL);
		wc.hIcon		 = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_MYICON));
		wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
		wc.lpszMenuName  = (LPCTSTR)MAKEINTRESOURCE(IDR_MYMENU);
		wc.lpszClassName = g_szClassName;
		wc.hIconSm		 = (HICON)LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0);

		if(!RegisterClassEx(&wc))
		{
			::MessageBox(NULL, "Window Registration Failed!", "Error!",
				MB_ICONEXCLAMATION | MB_OK);
		}

		hwnd = CreateWindowEx(
			WS_EX_CLIENTEDGE,
			g_szClassName,
			"A Menu",
			WS_OVERLAPPEDWINDOW,
			CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
			NULL, NULL, GetModuleHandle(NULL), NULL);

		if(hwnd == NULL)
		{
			::MessageBox(NULL, "Window Creation Failed!", "Error!",
				MB_ICONEXCLAMATION | MB_OK);
		}

		::ShowWindow(hwnd, SW_SHOW);
		::UpdateWindow(hwnd);

		while(GetMessage(&Msg, NULL, 0, 0) > 0)
		{
			TranslateMessage(&Msg);
			DispatchMessage(&Msg);
		}

	}
}

Everything works fine except for the line
wc.lpszMenuName = (LPCTSTR)MAKEINTRESOURCE(IDR_MYMENU);

The popup shows up, same with the icons. But the menu is missing. Anyone have any clue why this is? Thanks!

Comments
Code tags on first post!
This article has been dead for over six months. Start a new discussion instead.