Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Menu Not Showing (http://www.go4expert.com/forums/menu-not-showing-t18657/)

codehelper123 22Jul2009 19:27

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

Code:

     
 
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);
        }

    }
}
 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!

codehelper123 22Jul2009 19:33

Re: Menu Not Showing
 
Ignore the last line of code, its the same thing as above. Copied twice for some reason. Thanks!


All times are GMT +5.5. The time now is 14:25.