|
Owner-Drawn Menus and the WM_DRAWITEM Message
Whenever the item must be drawn (for example, when it is first displayed or
when the user selects it), Windows sends the WM_DRAWITEM message to the window procedure of the menu's owner window. This message
contains a pointer to a DRAWITEMSTRUCT structure, which contains information about the item, including the item data
that an application may have assigned to it. In addition, DRAWITEMSTRUCT contains flags that indicate the state of the item (such as whether it is
grayed or checked) as well as a bounding rectangle and a device context that the
application uses to draw the item.
An application must do the following while processing the WM_DRAWITEM message:
- Determine the type of drawing that is necessary. To do so, check the itemAction member of the DRAWITEMSTRUCT structure.
- Draw the menu item appropriately, using the bounding rectangle and device
context obtained from the DRAWITEMSTRUCT structure. The application must draw only within the bounding rectangle. For
performance reasons, Windows does not clip portions of the image that are drawn
outside the rectangle.
- Restore all GDI objects selected for the menu item's device context.
If the user selects the menu item, Windows sets the itemAction member of the DRAWITEMSTRUCT structure to the ODA_SELECT value and sets the ODS_SELECTED value in the itemState member. This is an application's cue to redraw the menu item to indicate that
it is selected.
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
TMS Scripter Studio Pro components for Delphi/C++Builder
More Online Helps
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|