|
-
Nov 16th, 2000, 01:16 PM
#1
Thread Starter
Frenzied Member
How can i put a new font to a label. I try that
label1.font = "c:\windows\fonts\?????.TTF"
But it does'nt work, the font change , but just once
and whatever font i put it's always the same!
-
Nov 16th, 2000, 01:25 PM
#2
Guru
Code:
MyLabel.Font.Name = "Arial"
Simple and easy.
-
Nov 16th, 2000, 03:02 PM
#3
Fanatic Member
The decimal point is optional.
Uppercase and lowercase characters are the same, meaning that "Arial" equals "arial".
Code:
MyLabel.FontName = "Arial"
-
Nov 16th, 2000, 04:23 PM
#4
PowerPoster
If you want to let the user choose what font to use, just load the fonts into a listbox/combo box, then set the font using text1.font = list1.text or combo1.text. The code to load the fonts into a listbox is below.
Code:
Private Sub Form_Load()
Dim intCount
For intCount = 1 To Screen.FontCount
List1.AddItem Screen.Fonts(intCount)
Next intCount
End Sub
-
Nov 20th, 2000, 01:35 PM
#5
Fanatic Member
You can also use the EnumFonts API:
Code:
'in a form
Private Sub Form_Load()
Me.AutoRedraw = True
EnumFonts Me.hDC, vbNullString, AddressOf EnumFontProc, 0
End Sub
'in a module
Private Const LF_FACESIZE = 32
Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(LF_FACESIZE) As Byte
End Type
Declare Function EnumFonts Lib "gdi32" Alias "EnumFontsA" (ByVal hDC As Long, ByVal lpsz As String, ByVal lpFontEnumProc As Long, ByVal lParam As Long) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Function EnumFontProc(ByVal lplf As Long, ByVal lptm As Long, ByVal dwType As Long, ByVal lpData As Long) As Long
Dim LF As LOGFONT, FontName As String, ZeroPos As Long
CopyMemory LF, ByVal lplf, LenB(LF)
FontName = StrConv(LF.lfFaceName, vbUnicode)
ZeroPos = InStr(1, FontName, Chr$(0))
If ZeroPos > 0 Then FontName = Left$(FontName, ZeroPos - 1)
Form1.Print FontName
EnumFontProc = 1
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|