locked
Wrong Icon On Title Bar, revisited RRS feed

  • Question

  • I'm developing a win32 application with Visual Studio 2008 on Windows Vista. I specify the iron resource in the resource file:
    IDI_MEXPLORER           ICON DISCARDABLE "..\\resource\\icon\\mexplorer.ico"

    However, I get a generic application icon on my title bar. What's weird is that it is ONLY in the title bar where I get the generic icon. In the taskbar, Windows explorer, and in the desktop shortcut, the icon is the correct one.

    The code that load the icon is:

       WNDCLASS wndclass;
     
       hInst = hInstance;
     
       wndclass.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
       wndclass.lpfnWndProc   = WndProc;
       wndclass.cbClsExtra    = 0;
       wndclass.cbWndExtra    = 0;
       wndclass.hInstance     = hInstance;
       wndclass.hIcon         = LoadIcon(NULL, MAKEINTRESOURCE(IDI_MEXPLORER));
       wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
       wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
       wndclass.lpszMenuName  = szAppName;
       wndclass.lpszClassName = szAppName;

    Sunday, June 12, 2011 4:08 PM

Answers

  • Leonard2007 wrote:

    wndclass.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_MEXPLORER));

    If IDI_MEXPLORER is a custom icon included in your app's resources, then  the first parameter should be the HINSTANCE of your app, not NULL.


    Igor Tandetnik

    • Marked as answer by Leonard2007 Monday, June 13, 2011 3:03 PM
    Sunday, June 12, 2011 6:29 PM
  • use

    wndclass.hIcon         = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_MEXPLORER));

    instadeof

    wndclass.hIcon         = LoadIcon(NULL, MAKEINTRESOURCE(IDI_MEXPLORER));

    • Marked as answer by Leonard2007 Monday, June 13, 2011 3:03 PM
    Monday, June 13, 2011 9:16 AM

All replies