imports system.io
imports system.reflection
imports system.runtime.interopservices
imports system.diagnostics.fileversioninfo
public class usercontrol1
public structure mousehookstruct
public pt as point
public hwnd as intptr
public hittest as int32
public extra as int32
end structure
public delegate function callback(byval ncode as int32, byval wparam as intptr, byref lparam as mousehookstruct) as int32
<marshalas(unmanagedtype.functionptr)> private _mouseproc as callback
private declare function setwindowshookexw lib "user32.dll" (byval idhook as int32, byval hookproc as callback, byval hinstance as intptr, byval wparam as int32) as int32
private declare function callnexthookex lib "user32.dll" (byval idhook as int32, byval ncode as int32, byval wparam as intptr, byref lparam as mousehookstruct) as int32
private declare function getcurrentthreadid lib "kernel32.dll" () as integer
private lngmousehook as long
public event myclick(byval sender as object, byval e as system.eventargs)
private const wm_lbuttonup as integer = &h202
private sub usercontrol1_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load
_mouseproc = new callback(addressof mousehook)
lngmousehook = setwindowshookexw(7, _mouseproc, intptr.zero, getcurrentthreadid())
end sub
public function mousehook(byval ncode as int32, byval wparam as intptr, byref lparam as mousehookstruct) as int32
if lparam.hwnd = handle or lparam.hwnd = me.label1.handle or lparam.hwnd = me.picturebox1.handle then
if wparam = wm_lbuttonup then
raiseevent myclick(me, system.eventargs.empty)
end if
end if
return callnexthookex(7, ncode, wparam, lparam)
end function
end class