Basic Univers
#WINSTA_ALL = #WINSTA_ACCESSCLIPBOARD | #WINSTA_ACCESSGLOBALATOMS | #WINSTA_CREATEDESKTOP | #WINSTA_ENUMDESKTOPS | #WINSTA_ENUMERATE | #WINSTA_EXITWINDOWS | #WINSTA_READATTRIBUTES | #WINSTA_READSCREEN | #WINSTA_WRITEATTRIBUTES | #DELETE | #READ_CONTROL | #WRITE_DAC | #WRITE_OWNER
#DESKTOP_ALL = #DESKTOP_READOBJECTS | #DESKTOP_CREATEWINDOW | #DESKTOP_CREATEMENU | #DESKTOP_HOOKCONTROL | #DESKTOP_JOURNALRECORD | #DESKTOP_JOURNALPLAYBACK | #DESKTOP_ENUMERATE | #DESKTOP_WRITEOBJECTS | #DESKTOP_SWITCHDESKTOP | #STANDARD_RIGHTS_REQUIRED
Global FontID1
FontID1 = LoadFont(1, "Arial", 22, #PB_Font_Bold)
Procedure Abort(s.s)
MessageRequester("", "Error: " + s.s)
Debug "Error: " + s.s
End
EndProcedure
Procedure Chk(a.l, s.s)
If Not(a)
If s.s
Abort(s.s)
Else
End
EndIf
EndIf
EndProcedure
hWinSta = OpenWindowStation_("WinSta0", 0, #WINSTA_ALL)
Chk( SetProcessWindowStation_(hWinSta) , "Failed to set window station")
hDefaultDesk = OpenDesktop_("Default", #DF_ALLOWOTHERACCOUNTHOOK, 0, #DESKTOP_SWITCHDESKTOP)
Chk(hDefaultDesk, "Failed to open default desktop")
hDesk = CreateDesktop_("My Desktop 2", 0, 0, #DF_ALLOWOTHERACCOUNTHOOK, #DESKTOP_ALL, 0)
Chk( hDesk, "Failed to create desktop")
SetThreadDesktop_(hDesk)
Chk( SwitchDesktop_(hDesk), "Failed to switch desktop")
If OpenWindow(1, 216, 0, 255, 165, "Test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(1))
TextGadget(1, 20, 70, 210, 30, "Test", #PB_Text_Center)
SetGadgetFont(1, FontID1)
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
WindowID = EventWindow()
GadgetID = EventGadget()
EventType = EventType()
If Event = #PB_Event_Gadget
EndIf
Until Event = #PB_Event_CloseWindow
Chk( SwitchDesktop_(hDefaultDesk), "Failed to switch desktop")
SetThreadDesktop_(hDefaultDesk)
CloseDesktop_(hDesk)
CloseDesktop_(hDefaultDesk)
CloseWindowStation_(hWinSta)