If
wMsg = WM_MEASUREITEM Then
Dim MIS As MEASUREITEMSTRUCT
CopyMemory MIS, ByVal lParam, Len(MIS)
If WM_MEASUREITEM
message is received, declare a variable of type MEASUREITEMSTRUCT
(we could have declared it anywhere, it doesn't matter) and
then copy the data from the structure pointed by lParam into
MIS. Note: as MIS is passed by reference (ByRef - default),
the address of the structure, rather than the data, is passed
to CopyMemory. Thus, lParam must be passed by value (ByVal)
so that CopyMemory receives the value of the variable and not
its address. Now, data with length of MIS structure will be
copied from lParam location in memory to the address of MIS
structure (and actually into it).
If
MIS.itemData = 0 Then
MIS.itemHeight = Form1.Picture1.ScaleHeight
MIS.itemWidth = Form1.Picture1.ScaleWidth - 12
If the menu
item is the first one (New), set the width and height according
to the size of Picture1 and Picture2. Note that picture boxes'
properties ScaleMode are set to Pixels (Windows works with pixels,
not twips).
ElseIf MIS.itemData = 1 Then
MIS.itemHeight = Form1.Picture2.ScaleHeight
MIS.itemWidth = Form1.Picture2.ScaleWidth - 12
If it is
the second menu item, set its width and height...
...
Go on this
way for all menu items (itemData values 0 to 5)