SAMPLE: Owner-Draw: 3-D Push Button Made from Bitmaps with TextLast reviewed: February 15, 1996Article ID: Q64328 |
The information in this article applies to:
SUMMARYAn owner-draw button can be defined and drawn to provide any desired appearance, even to mimic the three-dimensional push buttons of Windows version 3.0. With an owner-draw button, the application can control the button face color, unlike a standard push button, which always has a gray face.
MORE INFORMATIONODBUTTON is a file in the Microsoft Software Library that contains an example of an owner-draw button. The button uses two 64-by-64-bit bitmaps. The first bitmap represents the default button state. In this state, the button has a light gray face, a light left and upper border, and the button's text is centered in the bitmap. The second bitmap represents the pressed button state. In this state, the button has a solid, dark gray face, and the button's text is shifted to the right and down two pixels.
Download ODBUTTON.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:
Under Windows 2.x, an application can change the color of the button face by processing WM_CTLCOLOR messages. This functionality is not available in Windows 3.0. However, the more powerful owner-draw feature can be used to achieve the same effect. Like a Windows 3.0 standard push button, this sample owner-draw button indicates that it has the focus by drawing a dashed, black rectangular border around the button text. This is accomplished by using the new Windows 3.0 function, DrawFocusRect(). Like the text of the button, the focus rectangle must also be shifted right and down two pixels when the button is pressed. Bitmaps are created in a fixed size, in pixels, regardless of the display resolution used. An application can determine which display is in use by reading the SYSTEM.INI file. Two alternatives are available to create buttons that are an appropriate size on different displays, as follows:
Like other owner-draw controls, the application draws the owner-draw button in response to a WM_DRAWITEM message. Drawing should take into account the selection and focus states of the control, as well as the normal state without either selection or focus.
|
Additional reference words: 3.00 3.10 softlib ODBUTTON.EXE
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |