Should be multiplatform
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Import ""
PB_Object_EnumerateStart(PB_Objects)
PB_Object_EnumerateNext(PB_Objects, *ID.Integer)
PB_Object_EnumerateAbort(PB_Objects)
PB_Object_GetObject(PB_Object , DynamicOrArrayID)
PB_Window_Objects
EndImport
CompilerElse
ImportC ""
PB_Object_EnumerateStart(PB_Objects)
PB_Object_EnumerateNext(PB_Objects, *ID.Integer)
PB_Object_EnumerateAbort(PB_Objects)
PB_Object_GetObject(PB_Object , DynamicOrArrayID)
PB_Window_Objects.i
EndImport
CompilerEndIf
Procedure WinExists(Title$)
Protected titlefound$
PB_Object_EnumerateStart(PB_Window_Objects)
While PB_Object_EnumerateNext(PB_Window_Objects, @object)
If IsWindow(object)
titlefound$= GetWindowTitle(object)
If titlefound$=Title$
result=#True
Break
Else
result=#False
EndIf
EndIf
Wend
PB_Object_EnumerateAbort(PB_Objects)
ProcedureReturn result
EndProcedure
win=10
OpenWindow(win, 50, 50, 222, 150, "Tests10", #PB_Window_SystemMenu|#PB_Window_NoActivate )
ButtonGadget(0, 10, 10, 200, 25, "Standard Button")
ButtonGadget(1, 10, 40, 200, 25, "Left Button", #PB_Button_Left)
OpenWindow(1, 300, 50, 222, 150, "Tests1", #PB_Window_SystemMenu)
OpenWindow(2, 50, 300, 222, 150, "Tests2", #PB_Window_SystemMenu|#PB_Window_Invisible )
ww=OpenWindow(#PB_Any,300,300,200,150,"#PB_Any", #PB_Window_SystemMenu|#PB_Window_Tool)
Debug WinExists("Tests10");1
Debug WinExists("Tests2");1
Debug WinExists("Tests1");1
Debug WinExists("Tests");0
Debug WinExists("#PB_Any");1
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow