betritt oder wieder verlaesst. Gibt es nur nicht fuer alle Windows Versionen.
Folgende 2 Beispiele zeigen wie es auch ohne TrackMouseEvent geht.
Fuer Fenster :
Code: Alles auswählen
Procedure CaptureMouseEventsOnWindowCB(hWnd,uMsg,wParam,lParam)
Protected rc.rect,pt.point,pt2.point
Protected OldProc.l = GetWindowLong_(hWnd,#GWL_USERDATA)
If #WM_MOUSEMOVE = uMsg
GetClientRect_(hWnd,rc)
pt\x = (lparam & $0000FFFF)
pt\y = (lparam >> 16)
pt2\x = pt\x
pt2\y = pt\y
ClientToScreen_(hWnd,pt2)
If PtInRect_(rc,pt\x,pt\y) And WindowFromPoint_(pt2\x,pt2\y) = hWnd
If Not GetCapture_() = hWnd
SetCapture_(hWnd)
Debug "ENTER : WIN = " + Str(GetProp_(Hwnd,"PB_WindowID")-1)
EndIf
Else
Debug "LEAVE : WIN = " + Str(GetProp_(Hwnd,"PB_WindowID")-1)
ReleaseCapture_()
EndIf
EndIf
ProcedureReturn CallWindowProc_(OldProc,hWnd,uMsg,wParam,lParam)
EndProcedure
Procedure CaptureMouseEventsOnWindow(hWindow)
Protected oldProc = SetWindowLong_(hWindow,#GWL_WNDPROC,@CaptureMouseEventsOnWindowCB())
SetWindowLong_(hWindow,#GWL_USERDATA,oldProc)
EndProcedure
; TEST
Procedure Main()
Protected Event.l
OpenWindow(0,#PB_Ignore,#PB_Ignore,300,300,"Test")
OpenWindow(1,#PB_Ignore,#PB_Ignore,100,100,"Test")
CaptureMouseEventsOnWindow(WindowID(0))
CaptureMouseEventsOnWindow(WindowID(1))
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndProcedure:Main()
Code: Alles auswählen
Procedure CaptureMouseEventsOnGadgetCB(hWnd,uMsg,wParam,lParam)
Protected rc.rect
Protected OldProc.l = GetWindowLong_(hWnd,#GWL_USERDATA)
If #WM_MOUSEMOVE = uMsg
GetClientRect_(hWnd,rc)
If PtInRect_(rc,(lparam & $0000FFFF),(lparam >> 16))
If Not GetCapture_() = hWnd
SetCapture_(hWnd)
Debug "ENTER : GADGET = " + Str(GetProp_(Hwnd,"PB_ID"))
EndIf
Else
Debug "LEAVE : GADGET = " + Str(GetProp_(Hwnd,"PB_ID"))
ReleaseCapture_()
EndIf
EndIf
ProcedureReturn CallWindowProc_(OldProc,hWnd,uMsg,wParam,lParam)
EndProcedure
Procedure CaptureMouseEventsOnGadget(hGadget)
Protected oldProc = SetWindowLong_(hGadget,#GWL_WNDPROC,@CaptureMouseEventsOnGadgetCB())
SetWindowLong_(hGadget,#GWL_USERDATA,oldProc)
EndProcedure
;TEST
Procedure Main()
Protected Event.l
Protected hWnd.l
hWnd = OpenWindow(0,#PB_Ignore,#PB_Ignore,300,300,"Test")
CreateGadgetList(hWnd)
hBut0 = ButtonGadget(0,10,10,20,20,"0")
hBut1 = ButtonGadget(1,40,10,20,20,"1")
CaptureMouseEventsOnGadget(hBut0)
CaptureMouseEventsOnGadget(hBut1)
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndProcedure:Main()