Adding a font

I have a font that I got from the internet and I was wondering if there is a way to put this font into a visual basic program I am making.  I want the font to be in the program so anyone who uses the program doesn't have to have the font on their computer.
AmazedAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
tommy_boyConnect With a Mentor Commented:
You will still need to install it on their machine.

Use the following code.

Declare Function AddFontResource& Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String)
Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As _
Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Public Const HWND_BROADCAST = -1
Public Const WM_FONTCHANGE = &H1D

Example
Call AddFontResource("myfont.ttf")
Call SendMessage(HWND_BROADCAST, WM_FONTCHANGE, Ø, Ø)

Cheers!
0
All Courses

From novice to tech pro — start learning today.