; thinclient.pb
; ------------------------------------------------------------
; wrapper for mstsc.exe & vnc.exe (tvnviewer.exe) 
; LICENSE  : GPL
; AUTHOR   : Michael H.G. Schmidt
; EMAIL    : michael@schmidt2.de
; DATE     : 20240130
; ------------------------------------------------------------
;

; Get system drive
Global SYS$=GetEnvironmentVariable("SystemDrive")

Procedure StartRDP()
  ; start RDP ...
  dummy=RunProgram(SYS$ + "\tools\rdp.exe","/kiosk:cup /ontop /nodrives /noprinters /span","")
EndProcedure

Procedure StartVNC()
  ; start VNC ...
  dummy=RunProgram(SYS$ + "\tools\tvnviewer.exe")
EndProcedure


; Button handler procedure
Procedure ButtonHandler()
  
  Select EventGadget()    
    Case 0
      StartRDP()
      
    Case 1
      StartVNC()
      
  EndSelect

EndProcedure

;;;;;;;
; MAIN
;;;;;;;

; open window to hide all other windows on desktop ...
OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_BorderLess | #PB_Window_Maximize)
 
; set colour to windows blue ...
SetWindowColor(0, RGB($04,$92,$c2)) 

; Get window size
W = WindowWidth(0)
H = WindowHeight(0)

; Shrink factor for buttons
S=0.1

; position calculations for the buttons
X0=W/2-(W*S/2)

GAP=W*0.01
ButtonW=W*0.1
ButtonH=H*0.1

BX0=X0 - (ButtonW*2 + GAP)/2
BX1=BX0 + ButtonW + GAP

BY=H/2-ButtonH/2

; use a bigger font the buttons
LoadFont(0, "MS Shell Dlg", 16)
SetGadgetFont(#PB_Default, FontID(0))

; Create Buttons
ButtonGadget(0, BX0, BY, ButtonW, ButtonH, "Remote Desktop", #PB_Button_MultiLine)
BindGadgetEvent(0, @ButtonHandler())

ButtonGadget(1, BX1, BY, ButtonW, ButtonH, "VNC viewer", #PB_Button_MultiLine)
BindGadgetEvent(1, @ButtonHandler())

; MAIN LOOP
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

; IDE Options = PureBasic 5.73 LTS (Windows - x64)
; CursorPosition = 22
; Folding = -
; EnableXP