Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Determine fixed width fonts on users machine

Posted on 2008-06-12
7
Medium Priority
?
421 Views
Last Modified: 2010-05-18
I have created a richtextbox that a user can type over underlines with-out erasing the underline or increasing the lines sentence lenght Like this:
In the keypress event
If mnuUnderlineTyping.Checked = True Then
myrtf1.SelUnderline = True
SendKeys "{Delete}"

End If
This works perfect if the line was created using a fixed width font when creating the line. The line is created by using .selunderline = true and using the space bar.
I have found that almost all pc's have the following fixed width fonts:
Courier New and Lucida Console some pc' may have more or users can dowload and add more. The program loads all the users fonts into a combo box. Now i want to add another combobox that only displays fixed width fonts.
How?
0
Comment
Question by:isnoend2001
  • 2
  • 2
7 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21773514
Here is a previous answer in C#:
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_21566129.html

you can translate to vb.net, please ask if you have some difficulty
0
 

Author Comment

by:isnoend2001
ID: 21773814
Thanks jaime_olivares:
That looks like what i need, but i am using vb6 and don't know about converting it>
0
 

Accepted Solution

by:
isnoend2001 earned 0 total points
ID: 21776116
Option Explicit
in form
Private Sub Form_Load()
Dim LF As LOGFONT
    'set graphics mode to persistent
    Me.AutoRedraw = True
    'enumerates the fonts
    EnumFontFamiliesEx Me.hdc, LF, AddressOf EnumFontFamProc, ByVal 0&, 0

End Sub


in module
Public Const TMPF_FIXED_PITCH = &H1

Public 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 '

Type NEWTEXTMETRIC
    tmHeight As Long
    tmAscent As Long
    tmDescent As Long
    tmInternalLeading As Long
    tmExternalLeading As Long
    tmAveCharWidth As Long
    tmMaxCharWidth As Long
    tmWeight As Long
    tmOverhang As Long
    tmDigitizedAspectX As Long
    tmDigitizedAspectY As Long
    tmFirstChar As Byte
    tmLastChar As Byte
    tmDefaultChar As Byte
    tmBreakChar As Byte
    tmItalic As Byte
    tmUnderlined As Byte
    tmStruckOut As Byte
    tmPitchAndFamily As Byte
    tmCharSet As Byte
    ntmFlags As Long
    ntmSizeEM As Long
    ntmCellHeight As Long
    ntmAveWidth As Long
End Type

Declare Function EnumFontFamiliesEx Lib "gdi32" _
        Alias "EnumFontFamiliesExA" (ByVal hdc As Long, _
                                     lpLogFont As LOGFONT, _
                                     ByVal lpEnumFontProc As Long, _
                                     ByVal LParam As Long, _
                                     ByVal dw As Long) As Long

Function EnumFontFamProc(lpNLF As LOGFONT, lpNTM As NEWTEXTMETRIC, ByVal FontType As Long, LParam As Long) As Long

    Dim FaceName As String

    'print the form on Form1

    If (lpNLF.lfPitchAndFamily And _
       TMPF_FIXED_PITCH) = TMPF_FIXED_PITCH Then

        'convert the returned string to Unicode

        FaceName = StrConv(lpNLF.lfFaceName, vbUnicode)

        'Form1.Print Left$(FaceName, InStr(FaceName, vbNullChar) - 1)
       
    End If

    'continue enumeration

    EnumFontFamProc = 1

End Function
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21776117
no objection
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question