The following, adapted from the example in the Help file, demonstrates this :
Code: Select all
EnableExplicit
#couleur_bleu1 = $C8B594
#couleur_bleu2 = $AA7929
#couleur_orange = $1071FB
#couleur_vert = $1FE59C
#couleur_fenetre = $10E4FA
Define byBlue, wName$ = "Compiler "+ #PB_Compiler_Version
; :: --------includes ------------
CompilerIf #PB_Compiler_Version < 570
IncludeFile "D:\Outils\Basic\PB.includes\DPiScaling.pbi" ; can be provided on request
UseModule DPi_Scaling ; pour les macros
Debug "using DPiScaling module"
byBlue = #True
CompilerElse
; these macros do nothing
Macro DPi4(a1,a2,a3,a4)
a1,a2,a3,a4
EndMacro
Macro DPi(a1,a2)
a1,a2
EndMacro
Macro DPiX(a1)
a1
EndMacro
Macro DPiY(a1)
a1
EndMacro
CompilerEndIf
;.
;- test flag
; would be practical if PB 5.70 DPi compiler option could be set/reset programmatically...
#dpiAware = 01
If #dpiAware
; remember to manually CHECK the Dpi option box in Compiler options
wName$ + " DPi-aware"
If byBlue : wName$ + " (Blue's method)" : EndIf
Else
; remember to manually UNCHECK the Dpi option box in Compiler options
wName$ + " NOT DPi-aware"
EndIf
Debug wName$
;- creating window
Define winX, winY, winW, winH
winW = 320 : winH = 260
winX = 100 + #dpiAware * (winW+20)
winY = 100
If 0 = OpenWindow(0, dpi4(winX, winY, winW, winH), wName$, #PB_Window_SystemMenu)
End
EndIf
SetWindowColor(0,#couleur_orange)
;- window gadgets
Define gX, gY, gW, gH
gX = 4 : gY = 4
gW = winW-(gX*2) : gH = winH-(gY*2)
CanvasGadget(0, dpi4(gX, gY, gW, gH))
SetGadgetColor(0,#PB_Gadget_BackColor, #couleur_vert)
If StartDrawing(CanvasOutput(0))
DrawingMode(#PB_2DDrawing_Gradient)
BackColor(#couleur_bleu1)
FrontColor(#couleur_bleu2)
LinearGradient(gX, gY, gX, gH)
Box(dpi4(gX, gY, gW-gX*2, gH-gY*2))
BackColor(#couleur_orange)
FrontColor(#couleur_vert)
Circle(dpi(gW/2,gH/2-1), DPiX(gH/2-gY*2))
StopDrawing()
EndIf
ButtonGadget(1, dpi4(20,20,90,25),"Button A")
ButtonGadget(2, dpi4(20,50,90,25),"Button B")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
End
