Un petit code tout simple :
il permet de récupérer la police utiliser par défaut dans les fenêtres et gadgets et de la modifier
En gros, je récupère la police normale et je lui ajoute du gras ou du surlignage ou de l'italique.
Le code :
Code : Tout sélectionner
Procedure.l LoadWindowFont(Bold = -1, Italic = -1, UnderLine = -1)
Protected ncm.NONCLIENTMETRICS
ncm\cbSize = SizeOf(NONCLIENTMETRICS)
SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
If Bold = 0
ncm\lfMessageFont\lfWeight = 0
ElseIf Bold = 1
ncm\lfMessageFont\lfWeight = 700
EndIf
If Italic = 0
ncm\lfMessageFont\lfItalic = 0
ElseIf Italic = 1
ncm\lfMessageFont\lfItalic = 1
EndIf
If UnderLine = 0
ncm\lfMessageFont\lfUnderline = 0
ElseIf UnderLine = 1
ncm\lfMessageFont\lfUnderline = 1
EndIf
ProcedureReturn CreateFontIndirect_(@ncm\lfMessageFont)
EndProcedure
; Création de la fenêtre et de la GadgetList
If OpenWindow(0, 0, 0, 300, 300, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget) = 0 Or CreateGadgetList(WindowID(0)) = 0
End
EndIf
TextGadget(#PB_Any, 5, 5, 290, 20, "Police utilisée par windows")
FontID_0 = LoadWindowFont()
If FontID_0
TextGadget(0, 5, 25, 290, 20, "Police normale")
SetGadgetFont(0, FontID_0)
EndIf
FontID_1 = LoadWindowFont(1, -1, -1)
If FontID_1
TextGadget(1, 5, 45, 290, 20, "Police en gras")
SetGadgetFont(1, FontID_1)
EndIf
FontID_2 = LoadWindowFont(-1, 1,1)
If FontID_2
TextGadget(2, 5, 65, 290, 20, "Police en italique soulignée")
SetGadgetFont(2, FontID_2)
EndIf
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenu() ; Menus
EndSelect
Case #PB_Event_Gadget
Select EventGadget() ; Gadgets
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
; On supprime les polices chargées
If FontID_0
DeleteObject_(FontID_0)
EndIf
If FontID_1
DeleteObject_(FontID_1)
EndIf
If FontID_2
DeleteObject_(FontID_2)
EndIf
End