Basic Univers
Procedure Actualise()
Rapport.f = Val(GetGadgetText(4)) /((GetGadgetState(2) + 10) * 2.54) / Cos(ATan(Val(GetGadgetText(5)) / Val(GetGadgetText(4))))
SetGadgetText(7, StrF(Rapport, 5))
StartDrawing(ImageOutput())
Line(5, 21, 134, 0, RGB(255, 255, 255))
Line(5, 21, Round(Rapport + 0.5, 0), 0, 0)
StopDrawing()
SetGadgetState(8, UseImage(0))
EndProcedure
If OpenWindow(0, 0, 0, 150, 195, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Mesure")
If CreateGadgetList(WindowID())
TextGadget(1, 3, 3, 144, 15, "Taille de l'écran", #PB_Text_Center)
ComboBoxGadget(2, 3, 18, 144, 500)
For i = 10 To 30
AddGadgetItem(2, - 1, Str(i) + " pouces")
Next
SetGadgetState(2, 7)
TextGadget(3, 3, 45, 144, 15, "Résolution", #PB_Text_Center)
X = GetSystemMetrics_(#SM_CXSCREEN)
Y = GetSystemMetrics_(#SM_CYSCREEN)
Rapport.f = X /((GetGadgetState(2) + 10) * 2.54) / Cos(ATan(Y / X))
StringGadget(4, 3, 60, 144, 20, Str(X), #PB_String_Numeric)
StringGadget(5, 3, 80, 144, 20, Str(Y), #PB_String_Numeric)
TextGadget(6, 3, 105, 144, 15, "Rapport pixel / cm", #PB_Text_Center)
StringGadget(7, 3, 120, 144, 20, StrF(Rapport, 5))
CreateImage(0, 144, 30)
StartDrawing(ImageOutput())
FontID = LoadFont(0, "Tahoma", 8, #PB_Font_HighQuality)
Box(0, 0, 144, 30, RGB(0255, 255, 255))
DrawingMode(4)
Box(0, 0, 144, 30, RGB(0, 0, 120))
DrawingMode(1)
FrontColor(0, 0, 0)
DrawingFont(FontID)
Locate(5, 3)
DrawText("1 cm")
Line(5, 21, Round(Rapport + 0.5, 0), 0)
StopDrawing()
ImageGadget(8, 3, 160, 144, 30, UseImage(0))
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
Select EventGadgetID()
Case 2
Actualise()
Case 4
Actualise()
Case 5
Actualise()
EndSelect
EndIf
Until Event = #WM_CLOSE
EndIf
EndIf