none
Win32 C++: How do I change the window icon during runtime? RRS feed

Answers

  • SetClassLong(hWnd, GCL_HICON, icon);

    or

    CWindow:: SetIcon

    or

    CWnd:: SetIcon

    or

    SendMessage(hWnd, WM_SETICON, ICON_BIG, icon);

    SendMessage(hWnd, WM_SETICON, ICON_SMALL, icon);

    Saturday, September 1, 2007 6:04 PM

All replies

  • SetClassLong(hWnd, GCL_HICON, icon);

    or

    CWindow:: SetIcon

    or

    CWnd:: SetIcon

    or

    SendMessage(hWnd, WM_SETICON, ICON_BIG, icon);

    SendMessage(hWnd, WM_SETICON, ICON_SMALL, icon);

    Saturday, September 1, 2007 6:04 PM
  • Awsome, thanks!  Using SendMessage works perfectly.  I got it to work for loading an icon from the disk, but it does not work for loading a 24bit or 256 color bmp from the disk.

    My code for the icon is:

    HANDLE icon = LoadImage(fgDisplay.Instance, "c:\\icon.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
    SendMessage(instance, (UINT)WM_SETICON, ICON_BIG, (LPARAM)icon);

    This works fine.  Here is the code for loading the .bmp from disk, which doesn't work.

    HANDLE icon = LoadImage(fgDisplay.Instance, "c:\\icon.bmp", IMAGE_BITMAP, 32, 32, LR_LOADFROMFILE);
    SendMessage(instance, (UINT)WM_SETICON, ICON_BIG, (LPARAM)icon);

    And again, I've tried a 24bit bitmap and 8bit.

    Saturday, September 1, 2007 6:41 PM