Virtual Desktop

Just starting out? Need help? Post your questions and find answers here.
PWS32
User
User
Posts: 85
Joined: Sat May 10, 2003 1:02 pm
Location: Germany

Virtual Desktop

Post by PWS32 »

Hi,

i´m need to write a program for kioskmode and found this code in this forum,
im add a testwindow to this code, if this program running the testwindow comes up on the old desktop not on the new desktop, please help!

Warning! : if the program runing you cant switch to the old desktop, please push ctrl+alt+del and press the logoff button by the taskmgr and you see to the old desktop

Code: Select all

#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)

;Show an error
Procedure Abort(s.s)
  MessageRequester("", "Error: "+s.s)
  End
EndProcedure

;Check a result and ev. abort
Procedure Chk(a.l, s.s)
  ;If a is false, abort.
  ;If a is false and s contains an error message, show it before abort.
  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")
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


;Delay(2000)

Chk( SwitchDesktop_(hDefaultDesk), "Failed to switch desktop")

CloseDesktop_(hDesk)
CloseDesktop_(hDefaultDesk)
CloseWindowStation_(hWinSta) 
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Re: Virtual Desktop

Post by mskuma »

PWS32 wrote:Warning! : if the program runing you cant switch to the old desktop, please push ctrl+alt+del and press the logoff button by the taskmgr and you see to the old desktop
For me, pressing ctrl+alt+del didn't get me anywhere - I had to power off to recover.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Same problem here.
Do not run this snippet if you have only one monitor !!!

You might be interested with this userlib (PB4) i made for managing desktops.

Pick it here :
http://purebasic.myftp.org/?filename=fi ... ktopEx.zip

It could be interesting to extends the lib with these 'WinStation' features.
Let me know.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Post Reply