byval wparam as long, byval lparam as long) _
as long
dim di as drawitemstruct
if msg = wm_destroy then terminate (hwnd)
'处理自画消息
if msg = wm_drawitem then
copymemory di, byval lparam, len(di)
'判断是自画button
if di.ctltype = odt_button then
drawbutton di.hwnditem, di.hdc, di.rcitem, di.itemstate
'不返回vb的默认button绘制过程
subwndproc = 1
exit function
end if
end if
subwndproc = callwindowproc(prevwndproc, hwnd, msg, wparam, lparam)
end function
public sub init(hwnd as long)
prevwndproc = setwindowlong(hwnd, gwl_wndproc, addressof subwndproc)
end sub
public sub terminate(hwnd as long)
call setwindowlong(hwnd, gwl_wndproc, prevwndproc)
end sub
' -- 模块结束 -- '
3. form1中的代码:
option explicit
private sub form_load()
call init(me.hwnd)
end sub
private sub form_unload(cancel as integer)
call terminate(me.hwnd)