'From:  "Pascal Delcombel Wed Dec 11, 2002  4:45 pm
' Add / remove Windows font

'Install Font (just for windows's session, all application may see it)
'P. Delcombel / December 2002


Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
Declare Function RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" (ByVal lpFileName As String) As Long
Declare Function PostMessageW Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const HWND_BROADCAST = &HFFFF&
Const WM_FONTCHANGE = &H1D

dim FontFileName as string
dim FontName as string

FontFileName = "c:\windows\fonts\BusIndus.ttf" 'change as appropriate
FontName = "Business/Industrial" 'change as appropriate

AddFontResource(FontFileName)

CREATE MainForm AS QFORM
Width = 340
Height = 205
CREATE Bouton AS QCOOLBTN
font.name = FontName
Font.Bold = 1
Caption = "Et oui!"
Top = 32
Left = 125
Width = 45
END CREATE
END CREATE
MainForm.Showmodal
RemoveFontResource(FontFileName)


Sub AddFont(Filename As String) 
Dim lResult As Long
lResult = AddFontResource(FileName)
lResult = PostMessageW(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) 
End Sub
Sub RemoveFont(Filename As String) 
Dim lResult As Long
lResult = RemoveFontResource(FileName)
lResult = PostMessageW(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) 
End Sub