Code: Select all
EnableExplicit
Declare DrawColoredBox(NewColor)
; Windows only (5.71 LTS):
; If the desktop of my PC is scaled to a value > 100%, the canvas and box are of different sizes
; (canvas is bigger than the box by scale factor)
; This appears to be dependent of the compiler setting for DPI awareness - it is only broken if
; both conditions are met: DPI awareness on + desktop scale > 100%
Global Canvas_Color
Procedure TestWindow()
If OpenWindow(0, 200, 200, 400, 400, "Test window")
SetWindowColor(0, #Gray)
;SetGadgetColor(0, #PB_Gadget_BackColor, RGB(128, 128, 128))
Canvas_Color = CanvasGadget(#PB_Any, 50, 50, 300, 300)
DrawColoredBox(#Yellow)
Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndProcedure
Procedure DrawColoredBox(NewColor)
Protected w = GadgetWidth(Canvas_Color), h = GadgetHeight(Canvas_Color)
If StartDrawing(CanvasOutput(Canvas_Color))
Box(0, 0, w, h, NewColor)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, w, h, #Black)
StopDrawing()
EndIf
EndProcedure
TestWindow()