Owner-Draw Buttons with Bitmaps on Non-Standard Displays

Last reviewed: November 2, 1995
Article ID: Q67715
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.0 and 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

If an application contains an owner-draw button that paints itself with a bitmap, the application's resources must contain a set of bitmaps appropriate to each display type on which the application might run.

If the application's resources do not contain bitmaps suitable for the display on which the application is running, the application can use the default 3-D button appearance by changing the button style to BS_PUSHBUTTON from BS_OWNERDRAW.

Under Windows 95, there is a new style BS_BITMAP which applications might find easier to use.

Changing the style of a button is possible in Windows version 3.0; however, this technique is not guaranteed to be supported in future releases of Windows.

MORE INFORMATION

An owner-draw button can use bitmaps to paint itself. When an application contains this type of owner-draw button, it must also contain a set of bitmaps appropriate for each display type on which the application might run. Each set of bitmaps has a normal "up" bitmap and a depressed "down" bitmap to implement the 3-D effects. The most common standard Windows display types are: CGA, EGA, VGA, 8514/a, and Hercules Monochrome. The dimensions and aspect ratio of the display affect the appearance of the bitmap. For example, a monochrome bitmap designed for VGA will display correctly on an 8514/a and any other display with a 1:1 aspect ratio.

If an application determines that it does not contain an appropriate set of bitmaps for the current display type, then it should change the button style from BS_OWNERDRAW to BS_PUSHBUTTON. After the style has been changed and the button has been redrawn, the button will appear as a normal 3-D push button.

The following code fragment demonstrates how to change the style of a push button from owner-draw to normal:

    ...

    /*
     * hWndButton is assumed to be the handle to the button.
     * Note that lParam has a nonzero value, which forces the button
     * to be redrawn. This assures that the normal button appearance
     * will show after this message is sent.
     */
    SendMessage(hWndButton, BM_SETSTYLE, BS_PUSHBUTTON, 1L);

    ...


Additional reference words: 3.00 3.10 4.00 95
KBCategory: kbui
KBSubcategory: UsrCtl


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: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.