WM_PAINTICON Message Removed from Windows SDK Docs

Last reviewed: July 23, 1997
Article ID: Q88192
3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows version 3.1

SUMMARY

The WM_PAINTICON message is not listed in the "Programmer's Reference, Volume 3: Messages, Structures, and Macros" for version 3.1 of the Microsoft Windows Software Development Kit (SDK). The text below explains this decision and provides source code that enables an application to paint its own icon.

MORE INFORMATION

When an application for the Microsoft Windows operating system registers a window class, it specifies a handle to an appropriate icon in the hIcon member of the WNDCLASS data structure. This can be an application-specific icon loaded from the application's resources or the default application icon provided with Windows.

If the application includes its own icon, Windows sends a WM_PAINTICON message when the user minimizes the application. If the application passes the WM_PAINTICON message to the DefWindowProc function, Windows paints the icon in the appropriate location.

If the application specifies the default icon or no icon, Windows does not send a WM_PAINTICON message when the user minimizes the application; instead, it sends a WM_PAINT message. When the application receives the WM_PAINT message, it can either pass the message to DefWindowProc so that Windows will paint the default icon, or the application can paint the icon dynamically.

Because the application cannot process the WM_PAINTICON message, except to pass it to DefWindowProc, it has been removed from the documentation for version 3.1 of the Windows SDK.

The following code demonstrates how to process the WM_PAINT message to paint the icon. Given a window handle, the IsIconic function indicates whether the window is an icon:

   case WM_PAINT:
      {
      PAINTSTRUCT ps;

      BeginPaint(hWnd, &ps);
      if (IsIconic(hWnd))
         {
         SendMessage(hWnd, WM_ICONERASEBKGND, (WORD)ps.hdc, 0);
         DrawIcon(ps.hdc, 0, 0, hIcon);
         }
       EndPaint(hWnd, &ps);
       }
       break;

When the application processes the WM_QUERYDRAGICON message by returning the handle to its icon, Windows converts the icon to a cursor when the user drags the icon window with the mouse.

   case WM_QUERYDRAGICON:
      return hIcon;

Because the application paints the icon background when it processes the WM_PAINT message, the following code prevents the screen from flashing:

   case WM_ERASEBKGND:
      if (IsIconic(hWnd))
         return TRUE;
      else
         return DefWindowProc(...);
      break;

DefWindowProc erases the background.


Additional reference words: 3.10
KBCategory: kbprg
KBSubcategory: UsrDlgs
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.