Populate ListBox or Combobox with list of available fonts

Cosmos75

Registered User.
Local time
Today, 02:32
Joined
Apr 22, 2002
Messages
1,281
API: Enumerating System Fonts
http://www.mvps.org/access/api/api0033.htm

Has anyone used this before?

I am trying to do the same thing in Access 2000 but with no success.
:(

Got the CallBacks spreadsheet for the AddrOf() code
http://www.trigeminal.com/code/CallBacks.zip

I get a problem in the code for AddrOf() on this line
Code:
    ' Get the current VBA project
    ' The results of GetCurrentVBAProject seemed inconsistent, in our tests,
    ' so now we just check the project handle when the function returns.
    Call GetCurrentVbaProject(hProject)
I would get;
Run-time error '453'
Can't find DLL entry point EbGetExecuteProj in VBE6.DLL


I have changed the original declarations to
Code:
Private Declare Function GetCurrentVbaProject _
 Lib "VBE6.DLL" Alias "EbGetExecutingProj" _
 (hProject As Long) As Long
Private Declare Function GetFuncID _
 Lib "VBE6.DLL" Alias "TipGetFunctionId" _
 (ByVal hProject As Long, ByVal strFunctionName As String, _
 ByRef strFunctionId As String) As Long
Private Declare Function GetAddr _
 Lib "VBE6.DLL" Alias "TipGetLpfnOfFunctionId" _
 (ByVal hProject As Long, ByVal strFunctionId As String, _
 ByRef lpfn As Long) As Long
As I am using that version of VBA. It wouldn't work also with ieft as VBA332.DLL, I would get
Run-Time error '53'
File not found : VBA332.DLL


My guess is that this doesn't work in Access 2000. How do I accomplish this in Access 200, then?
 
It works but I have no idea how!

It works now.

Changed
Code:
Sub FillListWithFonts(ctl As Control)
Dim hDC As Long
    hDC = GetDC(fhWnd(ctl))
    ctl.RowSource = vbNullString
    EnumFontFamilies hDC, vbNullString, AddrOf("EnumFontFamProc"), ctl
    ReleaseDC fhWnd(ctl), hDC
End Sub
to
Code:
Sub FillListWithFonts(ctl As Control)
Dim hDC As Long
    hDC = GetDC(fhWnd(ctl))
    ctl.RowSource = vbNullString
[color=red][b]    EnumFontFamilies hDC, vbNullString, AddressOf EnumFontFamProc, ctl[/b][/color]
    ReleaseDC fhWnd(ctl), hDC
End Sub
Also need to make sure that the Row Source Type property for the listbox is set to Value List.

To be honest I have NO CLUE as to how this works!
:confused: :p
 
Ok, it KINDA works. It still doesn't give me ALL the fonts I have on my computer?
:confused:

Edit: There are fonts that are in the in the Row Source that aren't showing in the combobox?
MORE :confused:
 
Last edited:

Users who are viewing this thread

Back
Top Bottom