PRB: Application Icon Does Not Appear on Taskbar Button

ID: Q190983

The information in this article applies to:

SYMPTOMS

When you create a top-level window, a button is displayed on the taskbar with the window's title. However, the window's icon is not displayed, even when a valid icon handle is provided when you register the window class.

CAUSE

Windows CE stores handles to both the large icon and small icon in the window's internal class information. When the class is initially registered, the small icon handle is set to NULL and the large icon handle is set to the handle provided in the hIcon member of the WNDCLASS structure. Windows CE uses the small icon when displaying a button in the taskbar.

RESOLUTION

To set the small icon for a window, your application should send a WM_SETICON message to its window as follows:

   #define ICON_SMALL 0
   HICON hSmallIcon = LoadImage (hInstance,
                                 MAKEINTRESOURCE (IDI_APPICON),
                                 IMAGE_ICON,
                                 GetSystemMetrics (SM_CXSMICON),
                                 GetSystemMetrics (SM_CYSMICON),
                                 LR_DEFAULTCOLOR);
   .
   .

   LRESULT WINAPI WndProc (HWND hWnd, UINT uMsg,
                           WPARAM wParam, LPARAM lParam)
   {
      switch (uMsg)
      {
         case WM_CREATE:
            SendMessage (hWnd, WM_SETICON, (WPARAM)ICON_SMALL,
                         (LPARAM) hSmallIcon);
            return 0;

         case WM_SETICON:
            return DefWindowProc (hWnd, uMsg, wParam, lParam);
         .
         .
      }
      return 0;
   }

STATUS

This behavior is by design.

Additional query words:

Keywords          : kbIcon kbGrpUser kbWinCE100 kbWinCE200 kbWndwMsg 
Issue type        : kbprb

Last Reviewed: August 10, 1998