Solved

Determine fixed width fonts on users machine

Posted on 2008-06-12
7
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

751 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