Menu Not Showing

Discussion in 'C' started by codehelper123, Jul 22, 2009.

  1. codehelper123

    codehelper123 New Member

    Joined:
    Jul 22, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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!
     
  2. codehelper123

    codehelper123 New Member

    Joined:
    Jul 22, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Ignore the last line of code, its the same thing as above. Copied twice for some reason. Thanks!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice