Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I get a client machine's system font?

Posted on 2000-02-18
3
Medium Priority
?
158 Views
Last Modified: 2013-12-03
Hi,
I'm distributing a program which contains some command buttons. The captions for these buttons must be written in the client's system font.

How do I dynamically get the user's system font please?

Thanks,

  gizz
0
Comment
Question by:gizz
[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
3 Comments
 
LVL 1

Accepted Solution

by:
Catouch earned 200 total points
ID: 2534574
I suppose the font is stored in the registry, if it is, you can use this to get it:

Public Function GetRegKey(KeyRoot As HKEYS, KeyName As String, SubKeyRef As String, EmptyRead As Variant) As String
    Dim i               As Long                                 ' Loop Counter                              '
    Dim rc              As Long                                 ' Return Code                               '
    Dim hKey            As Long                                 ' Handle To An Open Registry Key            '
    Dim hDepth          As Long                                 '                                           '
    Dim sKeyVal         As String                               '                                           '
    Dim lKeyValType     As Long                                 ' Data Type Of A Registry Key               '
    Dim tmpVal          As String                               ' Tempory Storage For A Registry Key Value  '
    Dim KeyValSize      As Long                                 ' Size Of Registry Key Variable             '
   
    '-----------------------------------------------------------'
    ' Open RegKey Under KeyRoot {HKeY_LOCAL_MACHINe...}         '
    '-----------------------------------------------------------'
    rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey)  ' Open Registry Key                        '
       
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyerror              ' Handle error...                           '
   
    tmpVal = String$(1024, 0)                                   ' Allocate Variable Space                   '
    KeyValSize = 1024                                           ' Mark Variable Size                        '
   
    '-----------------------------------------------------------'
    ' Retrieve Registry Key Value...                            '
    '-----------------------------------------------------------'
    rc = RegQueryValueEx(hKey, SubKeyRef, 0, lKeyValType, tmpVal, KeyValSize)    ' Get/Create Key Value
                       
    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyerror              ' Handle errors
     
    tmpVal = Left$(tmpVal, InStr(tmpVal, Chr(0)) - 1)

    '-----------------------------------------------------------'
    ' Determine Key Value Type For Conversion...                '
    '-----------------------------------------------------------'
    Select Case lKeyValType                                     ' Search Data Types...
    Case REG_SZ, REG_EXPAND_SZ                                  ' String Registry Key Data Type
        sKeyVal = tmpVal                                        ' Copy String Value
    Case REG_DWORD                                              ' Double Word Registry Key Data Type
        For i = Len(tmpVal) To 1 Step -1                        ' Convert each Bit
            sKeyVal = sKeyVal + Hex(Asc(Mid(tmpVal, i, 1)))     ' Build Value Char. By Char.
        Next
        sKeyVal = Format$("&h" + sKeyVal)                       ' Convert Double Word To String
    End Select
   
    GetRegKey = sKeyVal                                         ' Return Value
    rc = RegCloseKey(hKey)                                      ' Close Registry Key
   
ExitHnd:
    Exit Function                                               ' Exit
   
GetKeyerror:    ' Cleanup After An error Has Occured...         '
    GetRegKey = EmptyRead                                       ' Set Return Val To empty String
    rc = RegCloseKey(hKey)                                      ' Close Registry Key
End Function
0
 

Author Comment

by:gizz
ID: 2534830
Yes - silly me !
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 5129761
wtf?
What registry key?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 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