Home   .......

Owner Drawn Menu Tutorial

Code: MyWndProc 2

Products  
eXamples  
Files  
e-Mail Us  
 

 

CopyMemory ByVal lParam, MIS, Len(MIS)
MyWndProc = 1

Copy MIS structure data back to the place where Windows expects to find it.

ElseIf wMsg = WM_DRAWITEM Then
Dim DIS As DRAWITEMSTRUCT
CopyMemory DIS, ByVal lParam, Len(DIS)

If WM_DRAWITEM is received, declare a variable of DRAWITEMSTUCT type and copy data from lParam location in memory to DIS.

If DIS.itemData = 0 Then
If (DIS.itemState And ODs_SELECTED) Then
BitBlt DIS.hdc, DIS.rcItem.Left, DIS.rcItem.Top, Form1.Picture7.ScaleWidth, Form1.Picture7.ScaleHeight, Form1.Picture7.hdc, 0&, 0&, SRCCOPY
DispStatus ("New Highlighted")
Else
BitBlt DIS.hdc, DIS.rcItem.Left, DIS.rcItem.Top, Form1.Picture1.ScaleWidth, Form1.Picture1.ScaleHeight, Form1.Picture1.hdc, 0&, 0&, SRCCOPY
End If

If it is the first menu item (itemData = 0), check its state. If menu item is to be drawn selected (highlighted), copy the image from Picture7 and display status, else - copy the image from Picture1. This is executed for each menu item (itemData 0 to 5). The only difference is for menu item 4 - the separator bar. We just don't check a state there - it looks always the same.

MyWndProc = 1

Return True (we've processed the message).

Else
MyWndProc = CallWindowProc(oldWndProc, Hwnd, wMsg, wParam, lParam)
End If

For any other message sent to our window, just call the default window procedure (the one we replaced when subclassing the window).

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