; English forum: ; Author: ; Date: Structure event id.l oldid.l pressed.l left.l right.l changed.l key.l EndStructure Global EventData.event,CursorPosition.POINT If GetSystemMetrics_(#SM_SWAPBUTTON)=0 EventData\right=#VK_RBUTTON EventData\left=#VK_LBUTTON Else EventData\right=#VK_LBUTTON EventData\left=#VK_RBUTTON EndIf Procedure info(text.s) StatusBarText(1, 0, text, 4) EndProcedure Procedure RightKlickEvent() If GetActiveWindow_()=WindowID() GetCursorPos_(CursorPosition) ID=WindowFromPoint_(CursorPosition\x,CursorPosition\y) If EventData\pressed=0 And GetAsyncKeyState_(EventData\right)<>0 EventData\oldid=ID EventData\pressed=2:mouse_event_(#MOUSEEVENTF_LEFTDOWN,0,0,0,0) result=1 ElseIf EventData\pressed=2 And GetAsyncKeyState_(EventData\right)=0 If ID=EventData\oldid result=1 EndIf mouse_event_(#MOUSEEVENTF_LEFTUP,0,0,0,0) EventData\key=2 EventData\pressed=0 EndIf EndIf ProcedureReturn result EndProcedure Procedure LeftKlickEvent() If GetActiveWindow_()=WindowID() GetCursorPos_(CursorPosition) ID=WindowFromPoint_(CursorPosition\x,CursorPosition\y) If ID<>EventData\id EventData\id=ID EventData\changed=1 EndIf If EventData\pressed=0 And GetAsyncKeyState_(EventData\left)<>0 EventData\oldid=ID EventData\pressed=1 result=1 ElseIf EventData\pressed=1 And GetAsyncKeyState_(EventData\left)=0 If ID=EventData\oldid result=1 EndIf EventData\pressed=0 EndIf EndIf If EventData\key>0:result=0:EventData\key-1:EndIf ProcedureReturn result EndProcedure Procedure ButtonState() ProcedureReturn EventData\pressed EndProcedure Procedure KlickID() ProcedureReturn EventData\oldid EndProcedure Procedure MouseOverGadget() result=EventData\changed EventData\changed=0 ProcedureReturn result EndProcedure Procedure MouseOverID() ProcedureReturn EventData\id EndProcedure OpenWindow(0, 100, 100, 400, 300,#PB_Window_SystemMenu,"Events") CreateStatusBar(1,WindowID()) CreateGadgetList(WindowID()) ButtonGadget(1, 160, 90, 80, 20, "Button-1") ButtonGadget(2, 160, 190, 80, 20, "Button-2") Repeat EventID = WaitWindowEvent() If RightKlickEvent() If ButtonState() Select KlickID() Case GadgetID(1):info("Button-1 Right-Down") Case GadgetID(2):info("Button-2 Right-Down") Default:info("---") EndSelect Else Select KlickID() Case GadgetID(1):info("Button-1 Right-Up") Case GadgetID(2):info("Button-2 Right-Up") Default:info("---") EndSelect EndIf ElseIf LeftKlickEvent() If ButtonState() Select KlickID() Case GadgetID(1):info("Button-1 Left-Down") Case GadgetID(2):info("Button-2 Left-Down") Default:info("---") EndSelect Else Select KlickID() Case GadgetID(1):info("Button-1 Left-Up") Case GadgetID(2):info("Button-2 Left-Up") Default:info("---") EndSelect EndIf ElseIf MouseOverGadget() Select MouseOverID() Case GadgetID(1):info("Button-1 Mouseover") Case GadgetID(2):info("Button-2 Mouseover") Default:info("---") EndSelect EndIf Until EventID = #PB_EventCloseWindow ; ExecutableFormat=Windows ; FirstLine=1 ; EnableXP ; DisableDebugger ; EOF