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 INFORMATIONThe following files are available for download from the Microsoft
Download Center. Click the file names below to download the files: http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. The ODBUTTON sample source code can be used as a template for creating other applications. The main task involves creating appropriate bitmaps. 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 query words:
Keywords : kbfile kbsample kbButton kbCtrl kbNTOS kbGrpUser kbWinOS |
Last Reviewed: December 8, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |