Code: Select all
DeclareModule Window
EnableExplicit
Declare Activate( Window )
Declare Deactivate( Window )
Declare Event( State = #True )
Declare WaitWindowClose( Window = #PB_All )
Declare BindWindowEvent( Window, *CallBack, Event = #PB_All )
Declare UnbindWindowEvent( Window, *CallBack, Event = #PB_All )
EndDeclareModule
Module Window
EnableExplicit
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Import ""
CompilerElse
ImportC ""
CompilerEndIf
PB_Object_EnumerateStart( PB_Objects )
PB_Object_EnumerateNext( PB_Objects, *ID.Integer )
PB_Object_EnumerateAbort( PB_Objects )
PB_Object_Count( PB_Objects )
PB_Window_Objects.i
PB_Gadget_Objects.i
PB_Image_Objects.i
EndImport
#PB_Event_Window = #PB_Event_FirstCustomValue
Procedure Event_Activate( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_ActivateWindow ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Deactivate( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_DeactivateWindow ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Repaint( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_Repaint ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_LeftClick( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_LeftClick ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_LeftDoubleClick( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_LeftDoubleClick ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_RightClick( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_RightClick ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Move( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_MoveWindow ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Size( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_SizeWindow ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Minimize( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_MinimizeWindow ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Maximize( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_MaximizeWindow ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Restore( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_RestoreWindow ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Close( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_CloseWindow ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Menu( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_Menu ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure Event_Gadget( )
If IsWindow( EventWindow())
SetEnvironmentVariable(Str(EventWindow()), Str(#PB_Event_Gadget ))
PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndProcedure
Procedure BindWindowEvent( Window, *CallBack, Event = #PB_All )
If Event = #PB_All
BindEvent( #PB_Event_Window, *CallBack, Window )
Else
BindEvent( Event, *CallBack, Window )
EndIf
EndProcedure
Procedure UnbindWindowEvent( Window, *CallBack, Event = #PB_All )
If Event = #PB_All
UnbindEvent( #PB_Event_Window, *CallBack, Window )
Else
UnbindEvent( Event, *CallBack, Window )
EndIf
EndProcedure
Procedure Activate( Window )
BindEvent(#PB_Event_DeactivateWindow, @Event_Deactivate( ),Window)
BindEvent(#PB_Event_ActivateWindow, @Event_Activate( ),Window)
BindEvent(#PB_Event_Repaint, @Event_Repaint( ),Window)
BindEvent(#PB_Event_LeftClick, @Event_LeftClick( ),Window)
BindEvent(#PB_Event_LeftDoubleClick, @Event_LeftDoubleClick( ),Window)
BindEvent(#PB_Event_RightClick, @Event_RightClick( ),Window)
BindEvent(#PB_Event_MoveWindow, @Event_Move( ),Window)
BindEvent(#PB_Event_SizeWindow, @Event_Size( ),Window)
BindEvent(#PB_Event_MinimizeWindow, @Event_Minimize( ),Window)
BindEvent(#PB_Event_MaximizeWindow, @Event_Maximize( ),Window)
BindEvent(#PB_Event_RestoreWindow, @Event_Restore( ),Window)
BindEvent(#PB_Event_CloseWindow, @Event_Close( ),Window)
BindEvent(#PB_Event_Menu, @Event_Menu( ),Window)
BindEvent(#PB_Event_Gadget, @Event_Gadget( ),Window)
EndProcedure
Procedure Deactivate( Window )
UnbindEvent(#PB_Event_DeactivateWindow, @Event_Deactivate( ),Window)
UnbindEvent(#PB_Event_ActivateWindow, @Event_Activate( ),Window)
UnbindEvent(#PB_Event_Repaint, @Event_Repaint( ),Window)
UnbindEvent(#PB_Event_LeftClick, @Event_LeftClick( ),Window)
UnbindEvent(#PB_Event_LeftDoubleClick, @Event_LeftDoubleClick( ),Window)
UnbindEvent(#PB_Event_RightClick, @Event_RightClick( ),Window)
UnbindEvent(#PB_Event_MoveWindow, @Event_Move( ),Window)
UnbindEvent(#PB_Event_SizeWindow, @Event_Size( ),Window)
UnbindEvent(#PB_Event_MinimizeWindow, @Event_Minimize( ),Window)
UnbindEvent(#PB_Event_MaximizeWindow, @Event_Maximize( ),Window)
UnbindEvent(#PB_Event_RestoreWindow, @Event_Restore( ),Window)
UnbindEvent(#PB_Event_CloseWindow, @Event_Close( ),Window)
UnbindEvent(#PB_Event_Menu, @Event_Menu( ),Window)
UnbindEvent(#PB_Event_Gadget, @Event_Gadget( ),Window)
EndProcedure
Procedure Event( State = #True )
If IsWindow( EventWindow())
If State = #True
ProcedureReturn Val( GetEnvironmentVariable( Str(EventWindow())) )
Else
Debug State
SetEnvironmentVariable(Str(EventWindow()), Str( State ))
;PostEvent(#PB_Event_Window, EventWindow(), EventGadget(), EventType(), EventData())
EndIf
EndIf
EndProcedure
Procedure WaitWindowClose( Window = #PB_All )
Protected EnumWindow
If PB_Window_Objects
PB_Object_EnumerateStart( PB_Window_Objects )
While PB_Object_EnumerateNext( PB_Window_Objects, @EnumWindow )
Activate( EnumWindow )
Wend
PB_Object_EnumerateAbort( PB_Window_Objects )
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_Window
Select Event()
Case #PB_Event_CloseWindow
If EventWindow() = Window
Break
Else
CloseWindow( EventWindow() )
If Not PB_Object_Count( PB_Window_Objects )
Break
EndIf
EndIf
EndSelect
Default
;
If Window ! #PB_All And Not IsWindow(Window)
Break
EndIf
EndSelect
ForEver
EndProcedure
EndModule
; example
UseModule Window
Procedure Event_Gadgets( )
If IsWindow( EventWindow())
Select EventType()
Case #PB_EventType_MouseEnter :Debug ""+EventGadget()+" 2_1_EventType_MouseEnter" ; The Mouse Cursor entered the Gadget
Case #PB_EventType_MouseLeave :Debug ""+EventGadget()+" 2_1_EventType_MouseLeave" ; The Mouse Cursor left the Gadget
Case #PB_EventType_MouseMove :Debug ""+EventGadget()+" 2_1_EventType_MouseMove" ; The Mouse Cursor moved
Case #PB_EventType_MouseWheel :Debug ""+EventGadget()+" 2_1_EventType_MouseWheel" ; The Mouse wheel was moved
Case #PB_EventType_LeftButtonDown :Debug ""+EventGadget()+" 2_1_EventType_LeftButtonDown" ; The left Mouse button was pressed
Case #PB_EventType_LeftButtonUp :Debug ""+EventGadget()+" 2_1_EventType_LeftButtonUp" ; The left Mouse button was released
Case #PB_EventType_LeftClick :Debug ""+EventGadget()+" 2_1_EventType_LeftClick" ; A click With the left Mouse button
Case #PB_EventType_LeftDoubleClick :Debug ""+EventGadget()+" 2_1_EventType_LeftDoubleClick" ; A double-click With the left Mouse button
Case #PB_EventType_RightButtonDown :Debug ""+EventGadget()+" 2_1_EventType_RightButtonDown" ; The right Mouse button was pressed
Case #PB_EventType_RightButtonUp :Debug ""+EventGadget()+" 2_1_EventType_RightButtonUp" ; The right Mouse button was released
Case #PB_EventType_RightClick :Debug ""+EventGadget()+" 2_1_EventType_RightClick" ; A click With the right Mouse button
Case #PB_EventType_RightDoubleClick :Debug ""+EventGadget()+" 2_1_EventType_RightDoubleClick" ; A double-click With the right Mouse button
Case #PB_EventType_MiddleButtonDown :Debug ""+EventGadget()+" 2_1_EventType_MiddleButtonDown" ; The middle Mouse button was pressed
Case #PB_EventType_MiddleButtonUp :Debug ""+EventGadget()+" 2_1_EventType_MiddleButtonUp" ; The middle Mouse button was released
Case #PB_EventType_Focus :Debug ""+EventGadget()+" 2_1_EventType_Focus" ; The Gadget gained keyboard focus
Case #PB_EventType_LostFocus :Debug ""+EventGadget()+" 2_1_EventType_LostFocus" ; The Gadget lost keyboard focus
Case #PB_EventType_KeyDown :Debug ""+EventGadget()+" 2_1_EventType_KeyDown" ; A key was pressed
Case #PB_EventType_KeyUp :Debug ""+EventGadget()+" 2_1_EventType_KeyUp" ; A key was released
Case #PB_EventType_Input :Debug ""+EventGadget()+" 2_1_EventType_Input" ; Text input was generated
Case #PB_EventType_Change :Debug ""+EventGadget()+" 2_1_EventType_Change" ; Content change.
Case #PB_EventType_DragStart :Debug ""+EventGadget()+" 2_1_EventType_DragStart" ; The user tries To start a Drag & Drop operation.
Case #PB_EventType_Up :Debug ""+EventGadget()+" 2_1_EventType_Up" ; The 'Up' button was pressed.
Case #PB_EventType_Down :Debug ""+EventGadget()+" 2_1_EventType_Down" ; The 'Down' button was pressed.
Case #PB_EventType_TitleChange :Debug ""+EventGadget()+" 2_1_EventType_TitleChange" ; The page title changed (Windows only).
Case #PB_EventType_StatusChange :Debug ""+EventGadget()+" 2_1_EventType_StatusChange" ; The status message changed (Windows only).
Case #PB_EventType_DownloadStart :Debug ""+EventGadget()+" 2_1_EventType_DownloadStart" ; A page download started (Windows, OS X).
Case #PB_EventType_DownloadProgress :Debug ""+EventGadget()+" 2_1_EventType_DownloadProgress" ; Progress info is available With GetGadgetAttribute() (Windows only).
Case #PB_EventType_DownloadEnd :Debug ""+EventGadget()+" 2_1_EventType_DownloadEnd" ; A page download ended Or aborted (Windows, OS X).
Case #PB_EventType_PopupWindow :Debug ""+EventGadget()+" 2_1_EventType_PopupWindow" ; A popup Window was blocked (Windows only).
Case #PB_EventType_PopupMenu :Debug ""+EventGadget()+" 2_1_EventType_PopupMenu" ; The popup menu was blocked (display a custom menu here) (Windows only).
EndSelect
EndIf
EndProcedure
Procedure Event_Window_1_1( )
Select Event()
Case #PB_Event_Menu :Debug ""+EventWindow()+" 1_1_Event_Menu" ; a menu has been selected
Case #PB_Event_Gadget :Debug ""+EventWindow()+" 1_1_Event_Gadget" ; a Gadget has been pushed
Case #PB_Event_SysTray :Debug ""+EventWindow()+" 1_1_Event_SysTray" ; an icon in the systray zone was clicked
Case #PB_Event_Timer :Debug ""+EventWindow()+" 1_1_Event_Timer" ; a timer has reached its timeout
Case #PB_Event_CloseWindow :Debug ""+EventWindow()+" 1_1_Event_CloseWindow" ; the Window close Gadget has been pushed
;Case #PB_Event_Repaint :Debug ""+EventWindow()+" 1_1_Event_Repaint" ; the Window content has been destroyed And must be repainted (useful For 2D graphics operations)
Case #PB_Event_SizeWindow :Debug ""+EventWindow()+" 1_1_Event_SizeWindow" ; the Window has been resized
Case #PB_Event_MoveWindow :Debug ""+EventWindow()+" 1_1_Event_MoveWindow" ; the Window has been moved
Case #PB_Event_MinimizeWindow :Debug ""+EventWindow()+" 1_1_Event_MinimizeWindow" ; the Window has been minimized
Case #PB_Event_MaximizeWindow :Debug ""+EventWindow()+" 1_1_Event_MaximizeWindow" ; the Window has been maximized
Case #PB_Event_RestoreWindow :Debug ""+EventWindow()+" 1_1_Event_RestoreWindow" ; the Window has been restored To normal Size (either from a minimum Or maximum Size)
Case #PB_Event_ActivateWindow :Debug ""+EventWindow()+" 1_1_Event_ActivateWindow" ; the Window has been activated (got the focus)
Case #PB_Event_DeactivateWindow :Debug ""+EventWindow()+" 1_1_Event_DeactivateWindow" ; the Window has been deactivated (lost the focus)
Case #PB_Event_WindowDrop :Debug ""+EventWindow()+" 1_1_Event_WindowDrop" ; a Drag & Drop operation was finished on a Window
Case #PB_Event_GadgetDrop :Debug ""+EventWindow()+" 1_1_Event_GadgetDrop" ; a Drag & Drop operation was finished on a Gadget
Case #PB_Event_RightClick :Debug ""+EventWindow()+" 1_1_Event_RightClick" ; a right Mouse button click has occurred on the Window. This can be useful To display a popup menu
Case #PB_Event_LeftClick :Debug ""+EventWindow()+" 1_1_Event_LeftClick" ; a left Mouse button click has occurred on the Window
Case #PB_Event_LeftDoubleClick :Debug ""+EventWindow()+" 1_1_Event_LeftDoubleClick" ; a left Mouse button double-click has occurred on the Window
EndSelect
EndProcedure
Procedure Event_Window_2_1( )
Select Event()
Case #PB_Event_Menu :Debug ""+EventWindow()+" 2_1_Event_Menu" ; a menu has been selected
Case #PB_Event_Gadget :Debug ""+EventWindow()+" 2_1_Event_Gadget" ; a Gadget has been pushed
Case #PB_Event_SysTray :Debug ""+EventWindow()+" 2_1_Event_SysTray" ; an icon in the systray zone was clicked
Case #PB_Event_Timer :Debug ""+EventWindow()+" 2_1_Event_Timer" ; a timer has reached its timeout
Case #PB_Event_CloseWindow :Debug ""+EventWindow()+" 2_1_Event_CloseWindow" ; the Window close Gadget has been pushed
;Case #PB_Event_Repaint :Debug ""+EventWindow()+" 2_1_Event_Repaint" ; the Window content has been destroyed And must be repainted (useful For 2D graphics operations)
Case #PB_Event_SizeWindow :Debug ""+EventWindow()+" 2_1_Event_SizeWindow" ; the Window has been resized
Case #PB_Event_MoveWindow :Debug ""+EventWindow()+" 2_1_Event_MoveWindow" ; the Window has been moved
Case #PB_Event_MinimizeWindow :Debug ""+EventWindow()+" 2_1_Event_MinimizeWindow" ; the Window has been minimized
Case #PB_Event_MaximizeWindow :Debug ""+EventWindow()+" 2_1_Event_MaximizeWindow" ; the Window has been maximized
Case #PB_Event_RestoreWindow :Debug ""+EventWindow()+" 2_1_Event_RestoreWindow" ; the Window has been restored To normal Size (either from a minimum Or maximum Size)
Case #PB_Event_ActivateWindow :Debug ""+EventWindow()+" 2_1_Event_ActivateWindow" ; the Window has been activated (got the focus)
Case #PB_Event_DeactivateWindow :Debug ""+EventWindow()+" 2_1_Event_DeactivateWindow" ; the Window has been deactivated (lost the focus)
Case #PB_Event_WindowDrop :Debug ""+EventWindow()+" 2_1_Event_WindowDrop" ; a Drag & Drop operation was finished on a Window
Case #PB_Event_GadgetDrop :Debug ""+EventWindow()+" 2_1_Event_GadgetDrop" ; a Drag & Drop operation was finished on a Gadget
Case #PB_Event_RightClick :Debug ""+EventWindow()+" 2_1_Event_RightClick" ; a right Mouse button click has occurred on the Window. This can be useful To display a popup menu
Case #PB_Event_LeftClick :Debug ""+EventWindow()+" 2_1_Event_LeftClick" ; a left Mouse button click has occurred on the Window
Case #PB_Event_LeftDoubleClick :Debug ""+EventWindow()+" 2_1_Event_LeftDoubleClick" ; a left Mouse button double-click has occurred on the Window
EndSelect
EndProcedure
Procedure Event_Window_2_2( )
Select Event()
Case #PB_Event_Menu :Debug ""+EventWindow()+" 2_2_Event_Menu" ; a menu has been selected
Case #PB_Event_Gadget :Debug ""+EventWindow()+" 2_2_Event_Gadget" ; a Gadget has been pushed
Case #PB_Event_SysTray :Debug ""+EventWindow()+" 2_2_Event_SysTray" ; an icon in the systray zone was clicked
Case #PB_Event_Timer :Debug ""+EventWindow()+" 2_2_Event_Timer" ; a timer has reached its timeout
Case #PB_Event_CloseWindow :Debug ""+EventWindow()+" 2_2_Event_CloseWindow" ; the Window close Gadget has been pushed
;Case #PB_Event_Repaint :Debug ""+EventWindow()+" 2_2_Event_Repaint" ; the Window content has been destroyed And must be repainted (useful For 2D graphics operations)
Case #PB_Event_SizeWindow :Debug ""+EventWindow()+" 2_2_Event_SizeWindow" ; the Window has been resized
Case #PB_Event_MoveWindow :Debug ""+EventWindow()+" 2_2_Event_MoveWindow" ; the Window has been moved
Case #PB_Event_MinimizeWindow :Debug ""+EventWindow()+" 2_2_Event_MinimizeWindow" ; the Window has been minimized
Case #PB_Event_MaximizeWindow :Debug ""+EventWindow()+" 2_2_Event_MaximizeWindow" ; the Window has been maximized
Case #PB_Event_RestoreWindow :Debug ""+EventWindow()+" 2_2_Event_RestoreWindow" ; the Window has been restored To normal Size (either from a minimum Or maximum Size)
Case #PB_Event_ActivateWindow :Debug ""+EventWindow()+" 2_2_Event_ActivateWindow" ; the Window has been activated (got the focus)
Case #PB_Event_DeactivateWindow :Debug ""+EventWindow()+" 2_2_Event_DeactivateWindow" ; the Window has been deactivated (lost the focus)
Case #PB_Event_WindowDrop :Debug ""+EventWindow()+" 2_2_Event_WindowDrop" ; a Drag & Drop operation was finished on a Window
Case #PB_Event_GadgetDrop :Debug ""+EventWindow()+" 2_2_Event_GadgetDrop" ; a Drag & Drop operation was finished on a Gadget
Case #PB_Event_RightClick :Debug ""+EventWindow()+" 2_2_Event_RightClick" ; a right Mouse button click has occurred on the Window. This can be useful To display a popup menu
Case #PB_Event_LeftClick :Debug ""+EventWindow()+" 2_2_Event_LeftClick" ; a left Mouse button click has occurred on the Window
Case #PB_Event_LeftDoubleClick :Debug ""+EventWindow()+" 2_2_Event_LeftDoubleClick" ; a left Mouse button double-click has occurred on the Window
EndSelect
EndProcedure
Procedure Event_Window_2_3( )
Select Event()
Case #PB_Event_Menu :Debug ""+EventWindow()+" 2_3_Event_Menu" ; a menu has been selected
Case #PB_Event_Gadget :Debug ""+EventWindow()+" 2_3_Event_Gadget" ; a Gadget has been pushed
Case #PB_Event_SysTray :Debug ""+EventWindow()+" 2_3_Event_SysTray" ; an icon in the systray zone was clicked
Case #PB_Event_Timer :Debug ""+EventWindow()+" 2_3_Event_Timer" ; a timer has reached its timeout
Case #PB_Event_CloseWindow :Debug ""+EventWindow()+" 2_3_Event_CloseWindow" ; the Window close Gadget has been pushed
;Case #PB_Event_Repaint :Debug ""+EventWindow()+" 2_3_Event_Repaint" ; the Window content has been destroyed And must be repainted (useful For 2D graphics operations)
Case #PB_Event_SizeWindow :Debug ""+EventWindow()+" 2_3_Event_SizeWindow" ; the Window has been resized
Case #PB_Event_MoveWindow :Debug ""+EventWindow()+" 2_3_Event_MoveWindow" ; the Window has been moved
Case #PB_Event_MinimizeWindow :Debug ""+EventWindow()+" 2_3_Event_MinimizeWindow" ; the Window has been minimized
Case #PB_Event_MaximizeWindow :Debug ""+EventWindow()+" 2_3_Event_MaximizeWindow" ; the Window has been maximized
Case #PB_Event_RestoreWindow :Debug ""+EventWindow()+" 2_3_Event_RestoreWindow" ; the Window has been restored To normal Size (either from a minimum Or maximum Size)
Case #PB_Event_ActivateWindow :Debug ""+EventWindow()+" 2_3_Event_ActivateWindow" ; the Window has been activated (got the focus)
Case #PB_Event_DeactivateWindow :Debug ""+EventWindow()+" 2_3_Event_DeactivateWindow" ; the Window has been deactivated (lost the focus)
Case #PB_Event_WindowDrop :Debug ""+EventWindow()+" 2_3_Event_WindowDrop" ; a Drag & Drop operation was finished on a Window
Case #PB_Event_GadgetDrop :Debug ""+EventWindow()+" 2_3_Event_GadgetDrop" ; a Drag & Drop operation was finished on a Gadget
Case #PB_Event_RightClick :Debug ""+EventWindow()+" 2_3_Event_RightClick" ; a right Mouse button click has occurred on the Window. This can be useful To display a popup menu
Case #PB_Event_LeftClick :Debug ""+EventWindow()+" 2_3_Event_LeftClick" ; a left Mouse button click has occurred on the Window
Case #PB_Event_LeftDoubleClick :Debug ""+EventWindow()+" 2_3_Event_LeftDoubleClick" ; a left Mouse button double-click has occurred on the Window
EndSelect
EndProcedure
Procedure Event_Window_1( )
Select Event( )
Case #PB_Event_Menu :Debug ""+EventWindow()+" 1_Event_Menu" ; a menu has been selected
Case #PB_Event_Gadget :Debug ""+EventWindow()+" 1_Event_Gadget" ; a Gadget has been pushed
Case #PB_Event_SysTray :Debug ""+EventWindow()+" 1_Event_SysTray" ; an icon in the systray zone was clicked
Case #PB_Event_Timer :Debug ""+EventWindow()+" 1_Event_Timer" ; a timer has reached its timeout
Case #PB_Event_CloseWindow :Debug ""+EventWindow()+" 1_Event_CloseWindow" ; the Window close Gadget has been pushed
;Case #PB_Event_Repaint :Debug ""+EventWindow()+" 1_Event_Repaint" ; the Window content has been destroyed And must be repainted (useful For 2D graphics operations)
Case #PB_Event_SizeWindow :Debug ""+EventWindow()+" 1_Event_SizeWindow" ; the Window has been resized
Case #PB_Event_MoveWindow :Debug ""+EventWindow()+" 1_Event_MoveWindow" ; the Window has been moved
Case #PB_Event_MinimizeWindow :Debug ""+EventWindow()+" 1_Event_MinimizeWindow" ; the Window has been minimized
Case #PB_Event_MaximizeWindow :Debug ""+EventWindow()+" 1_Event_MaximizeWindow" ; the Window has been maximized
Case #PB_Event_RestoreWindow :Debug ""+EventWindow()+" 1_Event_RestoreWindow" ; the Window has been restored To normal Size (either from a minimum Or maximum Size)
Case #PB_Event_ActivateWindow :Debug ""+EventWindow()+" 1_Event_ActivateWindow" ; the Window has been activated (got the focus)
Case #PB_Event_DeactivateWindow :Debug ""+EventWindow()+" 1_Event_DeactivateWindow" ; the Window has been deactivated (lost the focus)
Case #PB_Event_WindowDrop :Debug ""+EventWindow()+" 1_Event_WindowDrop" ; a Drag & Drop operation was finished on a Window
Case #PB_Event_GadgetDrop :Debug ""+EventWindow()+" 1_Event_GadgetDrop" ; a Drag & Drop operation was finished on a Gadget
Case #PB_Event_RightClick :Debug ""+EventWindow()+" 1_Event_RightClick" ; a right Mouse button click has occurred on the Window. This can be useful To display a popup menu
Case #PB_Event_LeftClick :Debug ""+EventWindow()+" 1_Event_LeftClick" ; a left Mouse button click has occurred on the Window
Case #PB_Event_LeftDoubleClick :Debug ""+EventWindow()+" 1_Event_LeftDoubleClick" ; a left Mouse button double-click has occurred on the Window
EndSelect
EndProcedure
Procedure Event_Window_2( )
Select Event( )
Case #PB_Event_Menu :Debug ""+EventWindow()+" 2_Event_Menu" ; a menu has been selected
Case #PB_Event_Gadget :Debug ""+EventWindow()+" 2_Event_Gadget" ; a Gadget has been pushed
Case #PB_Event_SysTray :Debug ""+EventWindow()+" 2_Event_SysTray" ; an icon in the systray zone was clicked
Case #PB_Event_Timer :Debug ""+EventWindow()+" 2_Event_Timer" ; a timer has reached its timeout
Case #PB_Event_CloseWindow :Debug ""+EventWindow()+" 2_Event_CloseWindow" ; the Window close Gadget has been pushed
;Case #PB_Event_Repaint :Debug ""+EventWindow()+" 2_Event_Repaint" ; the Window content has been destroyed And must be repainted (useful For 2D graphics operations)
Case #PB_Event_SizeWindow :Debug ""+EventWindow()+" 2_Event_SizeWindow" ; the Window has been resized
Case #PB_Event_MoveWindow :Debug ""+EventWindow()+" 2_Event_MoveWindow" ; the Window has been moved
Case #PB_Event_MinimizeWindow :Debug ""+EventWindow()+" 2_Event_MinimizeWindow" ; the Window has been minimized
Case #PB_Event_MaximizeWindow :Debug ""+EventWindow()+" 2_Event_MaximizeWindow" ; the Window has been maximized
Case #PB_Event_RestoreWindow :Debug ""+EventWindow()+" 2_Event_RestoreWindow" ; the Window has been restored To normal Size (either from a minimum Or maximum Size)
Case #PB_Event_ActivateWindow :Debug ""+EventWindow()+" 2_Event_ActivateWindow" ; the Window has been activated (got the focus)
Case #PB_Event_DeactivateWindow :Debug ""+EventWindow()+" 2_Event_DeactivateWindow" ; the Window has been deactivated (lost the focus)
Case #PB_Event_WindowDrop :Debug ""+EventWindow()+" 2_Event_WindowDrop" ; a Drag & Drop operation was finished on a Window
Case #PB_Event_GadgetDrop :Debug ""+EventWindow()+" 2_Event_GadgetDrop" ; a Drag & Drop operation was finished on a Gadget
Case #PB_Event_RightClick :Debug ""+EventWindow()+" 2_Event_RightClick" ; a right Mouse button click has occurred on the Window. This can be useful To display a popup menu
Case #PB_Event_LeftClick :Debug ""+EventWindow()+" 2_Event_LeftClick" ; a left Mouse button click has occurred on the Window
Case #PB_Event_LeftDoubleClick :Debug ""+EventWindow()+" 2_Event_LeftDoubleClick" ; a left Mouse button double-click has occurred on the Window
EndSelect
EndProcedure
Procedure Event_Window_3( )
Select Event( )
Case #PB_Event_Menu :Debug ""+EventWindow()+" 3_Event_Menu" ; a menu has been selected
Case #PB_Event_Gadget :Debug ""+EventWindow()+" 3_Event_Gadget" ; a Gadget has been pushed
Case #PB_Event_SysTray :Debug ""+EventWindow()+" 3_Event_SysTray" ; an icon in the systray zone was clicked
Case #PB_Event_Timer :Debug ""+EventWindow()+" 3_Event_Timer" ; a timer has reached its timeout
Case #PB_Event_CloseWindow :Debug ""+EventWindow()+" 3_Event_CloseWindow" ; the Window close Gadget has been pushed
;Case #PB_Event_Repaint :Debug ""+EventWindow()+" 3_Event_Repaint" ; the Window content has been destroyed And must be repainted (useful For 2D graphics operations)
Case #PB_Event_SizeWindow :Debug ""+EventWindow()+" 3_Event_SizeWindow" ; the Window has been resized
Case #PB_Event_MoveWindow :Debug ""+EventWindow()+" 3_Event_MoveWindow" ; the Window has been moved
Case #PB_Event_MinimizeWindow :Debug ""+EventWindow()+" 3_Event_MinimizeWindow" ; the Window has been minimized
Case #PB_Event_MaximizeWindow :Debug ""+EventWindow()+" 3_Event_MaximizeWindow" ; the Window has been maximized
Case #PB_Event_RestoreWindow :Debug ""+EventWindow()+" 3_Event_RestoreWindow" ; the Window has been restored To normal Size (either from a minimum Or maximum Size)
Case #PB_Event_ActivateWindow :Debug ""+EventWindow()+" 3_Event_ActivateWindow" ; the Window has been activated (got the focus)
Case #PB_Event_DeactivateWindow :Debug ""+EventWindow()+" 3_Event_DeactivateWindow" ; the Window has been deactivated (lost the focus)
Case #PB_Event_WindowDrop :Debug ""+EventWindow()+" 3_Event_WindowDrop" ; a Drag & Drop operation was finished on a Window
Case #PB_Event_GadgetDrop :Debug ""+EventWindow()+" 3_Event_GadgetDrop" ; a Drag & Drop operation was finished on a Gadget
Case #PB_Event_RightClick :Debug ""+EventWindow()+" 3_Event_RightClick" ; a right Mouse button click has occurred on the Window. This can be useful To display a popup menu
Case #PB_Event_LeftClick :Debug ""+EventWindow()+" 3_Event_LeftClick" ; a left Mouse button click has occurred on the Window
Case #PB_Event_LeftDoubleClick :Debug ""+EventWindow()+" 3_Event_LeftDoubleClick" ; a left Mouse button double-click has occurred on the Window
EndSelect
EndProcedure
Define Width =135
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Width - 35 ; bug in windows
CompilerEndIf
OpenWindow(1, 50, 100, Width, 205, "Event_1")
ButtonGadget(11,5,5,125,25,"1_1")
ButtonGadget(12,5,35,125,25,"1_2")
ButtonGadget(13,5,75,125,25,"1_3")
ButtonGadget(14,5,105,125,25,"1_4")
ButtonGadget(15,5,145,125,25,"1_5")
ButtonGadget(16,5,175,125,25,"1_6")
OpenWindow(2, 250, 100, Width, 205, "Event_2")
ButtonGadget(21,5,5,125,25,"2_1")
ButtonGadget(22,5,35,125,25,"2_2")
ButtonGadget(23,5,75,125,25,"2_3")
ButtonGadget(24,5,105,125,25,"2_4")
ButtonGadget(25,5,145,125,25,"2_5")
ButtonGadget(26,5,175,125,25,"2_6")
OpenWindow(3, 450, 100, Width, 205, "Event_3")
ButtonGadget(31,5,5,125,25,"3_1")
ButtonGadget(32,5,35,125,25,"3_2")
ButtonGadget(33,5,75,125,25,"3_3")
ButtonGadget(34,5,105,125,25,"3_4")
ButtonGadget(35,5,145,125,25,"3_5")
ButtonGadget(36,5,175,125,25,"3_6")
Procedure Event_Window_0( )
Select Event()
Case #PB_Event_Gadget
Select EventType()
Case #PB_EventType_LeftClick
Select EventGadget()
Case 1 :Activate( 1 )
Case 2 :Deactivate( 1 )
Case 3 :Activate( 2 )
Case 4 :Deactivate( 2 )
Case 5 :Activate( 3 )
Case 6 :Deactivate( 3 )
EndSelect
EndSelect
Case #PB_Event_CloseWindow
If MessageRequester("предупреждение","Закрыть это окно "+Str(EventWindow()),#PB_MessageRequester_YesNo ) = #PB_MessageRequester_Yes
CloseWindow(EventWindow())
EndIf
EndSelect
EndProcedure
;
OpenWindow(0, 600, 200, Width, 205, "Event_0", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ButtonGadget(1,5,5,125,25,"BindAllEvent_1")
ButtonGadget(2,5,35,125,25,"UnBindAllEvent_1")
ButtonGadget(3,5,75,125,25,"BindAllEvent_2")
ButtonGadget(4,5,105,125,25,"UnBindAllEvent_2")
ButtonGadget(5,5,145,125,25,"BindAllEvent_3")
ButtonGadget(6,5,175,125,25,"UnBindAllEvent_3")
BindWindowEvent( 0, @Event_Window_0());, #PB_Event_Gadget )
BindWindowEvent( 1, @Event_Window_1() )
BindWindowEvent( 2, @Event_Window_2() )
BindWindowEvent( 3, @Event_Window_3() )
BindWindowEvent( 1, @Event_Window_1_1() )
BindWindowEvent( 2, @Event_Window_2_3() )
BindWindowEvent( 2, @Event_Window_2_2() )
BindWindowEvent( 2, @Event_Window_2_1() )
BindWindowEvent( 1, @Event_Gadgets(), #PB_Event_Gadget )
BindWindowEvent( 2, @Event_Gadgets(), #PB_Event_Gadget )
BindWindowEvent( 3, @Event_Gadgets(), #PB_Event_Gadget )
WaitWindowClose( 0 )
Debug "close"
End