Code: Select all
CompilerIf Not Defined( CountWindow, #PB_Function ) And
Not Defined( CountWindow, #PB_Procedure )
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Import ""
CompilerElse
ImportC ""
CompilerEndIf
PB_Object_Count( *Object )
PB_Window_Objects.i
EndImport
ProcedureDLL CountWindow( )
ProcedureReturn PB_Object_Count( PB_Window_Objects )
EndProcedure
CompilerEndIf
ProcedureDLL BindPBEvent( Event, *EventCallBack, Window, Object, EventType ) ;Returns TRUE is purebasic event
If Event = #PB_All
BindEvent( #PB_Event_DeactivateWindow, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_ActivateWindow, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_LeftClick, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_CloseWindow, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_FirstCustomValue, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_Gadget, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_GadgetDrop, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_LeftClick, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_LeftDoubleClick, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_MaximizeWindow, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_Menu, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_MinimizeWindow, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_MoveWindow, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_Repaint, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_RestoreWindow, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_RightClick, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_SizeWindow, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_SysTray, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_Timer, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_WindowDrop, *EventCallBack, Window, Object, EventType)
; BindEvent( #PB_Event_None, *EventCallBack, Window, Object, EventType)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
BindEvent( #PB_Event_ClientConnected, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_ClientDisconnected, *EventCallBack, Window, Object, EventType)
BindEvent( #PB_Event_FileReceived, *EventCallBack, Window, Object, EventType)
CompilerEndIf
Else
BindEvent( Event, *EventCallBack, Window, Object, EventType)
EndIf
EndProcedure
Macro BindEvent( Event, EventCallBack, Window =-1, Object =-1, EventType =-1)
BindPBEvent( Event, EventCallBack, Window, Object, EventType )
EndMacro
Procedure WindowCallBack()
Select Event() ; WaitWindowEvent()
Case #PB_Event_ActivateWindow
Debug "#PB_Event_ActivateWindow "+EventWindow()
Case #PB_Event_MoveWindow
Debug "#PB_Event_MoveWindow "+EventWindow()
Case #PB_Event_SizeWindow
Debug "#PB_Event_SizeWindow "+EventWindow()
Case #PB_Event_DeactivateWindow
Debug "#PB_Event_DeactivateWindow "+EventWindow()
Case #PB_Event_CloseWindow
Debug "#PB_Event_CloseWindow "+EventWindow()
CloseWindow(EventWindow())
EndSelect
EndProcedure
Procedure CreateWindow(ParentID=0,Flag = #PB_Window_SystemMenu|#PB_Window_SizeGadget)
Static Count, Window =-1
Protected W=400,H=300
BindEvent( #PB_All, @WindowCallBack(), Window )
Window = OpenWindow(#PB_Any,0,0, W,H, "Window_"+Str(Count),Flag, ParentID)
ProcedureReturn Window
EndProcedure
Window = CreateWindow()
ResizeWindow(Window,#PB_Ignore,#PB_Ignore,300,300)
ResizeWindow(Window,300,300,#PB_Ignore,#PB_Ignore)
Repeat
If CountWindow()
WaitWindowEvent()
Else
Break
EndIf
ForEver