Die Parameter Umstellung für WindowFromPoint nervt mich etwas.
im englischen Forum habe ich nun folgendes gesehen:
anstatt
Code: Alles auswählen
hndl=WindowFromPoint_(cursor\y<<32|cursor\x)
Code: Alles auswählen
hndl=WindowFromPoint_(PeekQ(@cursor))
Democode aus dem englischen Forum:
Code: Alles auswählen
Procedure.l EventHoverGadget()
Protected cursor.POINT,hndl.l
GetCursorPos_(cursor.POINT)
hndl=WindowFromPoint_(PeekQ(@cursor))
If hndl
hndl=GetDlgCtrlID_(hndl)
If hndl
ProcedureReturn hndl
EndIf
EndIf
ProcedureReturn 0
EndProcedure
OpenWindow(1,0,0,400,100,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ButtonGadget(1,10,10,380,20,"Button 1") ;Please note that the first gadgetid start with 1
ButtonGadget(2,10,30,380,20,"Button 2")
hover=0
oldhover=hover
Repeat
event=WindowEvent()
Select event
Case #WM_MOUSEMOVE
hover=EventHoverGadget()
If hover<>oldhover
Select hover
Case 1 : SetGadgetText(1,"Hover")
Case 2 : SetGadgetText(2,"Hover")
EndSelect
Select oldhover
Case 1 : SetGadgetText(1,"Button 1")
Case 2 : SetGadgetText(2,"Button 2")
EndSelect
oldhover=hover
EndIf
EndSelect
Delay(1)
Until event = #PB_Event_CloseWindow
Mein alter Freund heißt Import:
Code: Alles auswählen
Import "USER32.lib"
WindowFromPoint32_(a.l,b.l) As "_WindowFromPoint"
EndImport
Procedure.l EventHoverGadget()
Protected cursor.POINT,hndl.l
GetCursorPos_(cursor.POINT)
hndl=WindowFromPoint32_(cursor\x,cursor\y)
If hndl
hndl=GetDlgCtrlID_(hndl)
If hndl
ProcedureReturn hndl
EndIf
EndIf
ProcedureReturn 0
EndProcedure
OpenWindow(1,0,0,400,100,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ButtonGadget(1,10,10,380,20,"Button 1") ;Please note that the first gadgetid start with 1
ButtonGadget(2,10,30,380,20,"Button 2")
hover=0
oldhover=hover
Repeat
event=WindowEvent()
Select event
Case #WM_MOUSEMOVE
hover=EventHoverGadget()
If hover<>oldhover
Select hover
Case 1 : SetGadgetText(1,"Hover")
Case 2 : SetGadgetText(2,"Hover")
EndSelect
Select oldhover
Case 1 : SetGadgetText(1,"Button 1")
Case 2 : SetGadgetText(2,"Button 2")
EndSelect
oldhover=hover
EndIf
EndSelect
Delay(1)
Until event = #PB_Event_CloseWindow