Basic Univers
; Auteur : le Soldat Inconnu
; Version de PB : 3.90
;
; Explication du programme :
; Police de Windows

;- Hauteur de la police
Procedure GetTextHeight(GetTextHeightFontID.l)
  Protected Image, Dimension.SIZE, HDC
  Image = CreateImage(#PB_Any, 1, 1)
  HDC = StartDrawing(ImageOutput(Image))
  If hDC
    DrawingFont(GetTextHeightFontID)
    GetTextExtentPoint32_(HDC, "o", 1, @Dimension.SIZE)
    StopDrawing()
  EndIf
  FreeImage(Image)
  ProcedureReturn Dimension\cy * 3 / 4
EndProcedure

;- Police par défaut de windows
FontID = GetStockObject_(#DEFAULT_GUI_FONT)


; Création de la fenêtre et de la GadgetList
If OpenWindow(0, 0, 0, 300, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget) = 0 Or CreateGadgetList(WindowID(0)) = 0
  End
EndIf

TextGadget(0, 0, 0, 300, 30, "Hauteur du texte = " + Str(GetTextHeight(FontID)))

FontID2 = LoadFont(1, "Tahoma", 20, #PB_Font_HighQuality)
TextGadget(1, 0, 30, 300, 50, "Hauteur du texte = " + Str(GetTextHeight(FontID2)))
SetGadgetFont(1, FontID2)

Repeat
  Event = WaitWindowEvent()
 
 
Until Event = #PB_Event_CloseWindow