Home   .......

Owner Drawn Menu Tutorial

WM_MEASUREITEM

Products  
eXamples  
Files  
e-Mail Us  
 

 

WM_MEASUREITEM message is send to the owner of an owner drawn menu before it is displayed. First parameter is used to specify what type of control has sent the message (besides menus, combo boxes, listboxes and other controls may be owner drawn). It is 0 for menu items. The second parameter points to MEASUREITEMSTRUCT type, containing information about the control sending the message. If we process the message (and we will), we should return true (1).

Public Type MEASUREITEMSTRUCT

CtlType As Long
CtlID As Long
itemID As Long
itemWidth As Long
itemHeight As Long
itemData As Long

End Type

When we receive WM_MEASUREITEMSTRUCT, we use CopyMemory API function to copy the data from its location in memory to a simple variable. Note that it is essential to pass the address location ByVal. Everything about CopyMemory and ByVal is also explained in Using API in VB ....

Then, we must fill ItemWidth and itemHeight data members (according to itemData) and copy our variable content back to its original location.

 
Copyright (c) 1999, Billy&George Software and Peter Dimitrov
Revised May 1999