Code: Select all
;oreintation handling and http demo
Declare drawspecs()
Declare timer()
Declare.l RDesktopHeight()
Declare.l RDesktopWidth()
Global width.l
Global height.l
If OpenWindow(0,0,0,RDesktopWidth(),RDesktopHeight(),"",#PB_Window_Background)
CanvasGadget(0,0,0,WindowWidth(0),WindowHeight(0),#PB_Canvas_Keyboard)
AddWindowTimer(0,33,2000)
BindEvent(#PB_Event_Timer,@timer())
drawspecs()
EndIf
Procedure timer()
If EventTimer()=33
If RDesktopWidth()<>width Or RDesktopHeight()<>height
width=RDesktopWidth()
height=RDesktopHeight()
ResizeWindow(0,0,0,RDesktopWidth(),RDesktopHeight())
ResizeGadget(0,0,0,WindowWidth(0),WindowHeight(0))
drawspecs()
EndIf
EndIf
EndProcedure
Procedure httpevent(Success, Result$, UserData)
Protected draw.l
draw=StartDrawing(CanvasOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
If Success
DrawText(1,60,"Network: Connected",RGB(255,255,255))
Else
DrawText(1,60,"Network: Disconnected",RGB(255,255,255))
EndIf
If draw : StopDrawing() : EndIf
EndProcedure
Procedure drawspecs()
Protected aspect$
If RDesktopWidth()>RDesktopHeight()
aspect$="Landscape"
Else
aspect$="Verticle"
EndIf
StartDrawing(CanvasOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
Box(0,0,WindowWidth(0),WindowHeight(0),RGB(0,0,0))
DrawText(1,1,"Resolution: "+Str(RDesktopWidth())+"x"+Str(RDesktopHeight()),RGB(255,255,255))
DrawText(1,33,"Aspect: "+aspect$,RGB(255,255,255))
StopDrawing()
HTTPRequest(#PB_HTTP_Get,"https://www.google.com","",@httpevent())
EndProcedure
Procedure.l RDesktopWidth()
Protected pixels.f
EnableJS
v_pixels=window.devicePixelRatio.toPrecision(21);
DisableJS
ExamineDesktops()
ProcedureReturn Val(StrF(pixels * ValF(Str(DesktopWidth(0)))))
EndProcedure
Procedure.l RDesktopHeight()
Protected pixels.f
EnableJS
v_pixels=window.devicePixelRatio.toPrecision(21);
DisableJS
ExamineDesktops()
ProcedureReturn Val(StrF(pixels * ValF(Str(DesktopHeight(0)))))
EndProcedure