EnumFontFamProc not being CalledBack by EnumFontFamilies
Hey Everyone,
Tough one here. Not my code, but I'm helping a friend.
Basically, she wants to get a list of Printer Fonts. In VB6 this is done using the EnumFontFamilies API call, which calls back a function in your VB App.
We cannot get this to work in VB.NET I *think* that the problem may lie in our structure definitions for two Structures that get used by EnumFontFamProc (LOGFONT and NEWTEXTMETRIC)
Anyways, I'd appreciate any advice anyone's got for us.
Thanks!
--Ben
See attached code. To trigger, just set mPrinter equal to the name of the printer (from PrintDialog box) and run the FillFonts function (like below):
Code:
Dim f As String
Dim prtdlg As PrintDialog = New PrintDialog
prtdlg.PrinterSettings = New Printing.PrinterSettings
If prtdlg.ShowDialog = DialogResult.OK Then
'Dim MyFonts As New cFonts(prtdlg.PrinterSettings.PrinterName)
EnumPrintFonts.mPrinter = prtdlg.PrinterSettings.PrinterName
EnumPrintFonts.FillFonts()
Me.lbFontList.Items.Clear()
For Each f In EnumPrintFonts.mFonts
Me.lbFontList.Items.Add(f)
Next
End If
i presume you are trying to enumerate the same fonts as are available to your system / controls as well as the printer. this can be done through the fontfamily.
VB Code:
Dim f As FontFamily
For Each f In FontFamily.Families
Console.WriteLine(f.Name)
Next
~ if a post is resolved, please mark it as [Resolved] protected string get_Signature(){return Censored;} [vbcode][php] please use code tags when posting any code [/php][/vbcode]
Thanks, but actually no I'm not. I'm able to get those fonts just fine, it's the Printer Fonts that are tricky.
.NET doesn't have any way to get the printer fonts (which I've discovered through web browsing) but old Windows API calls do. The problem lies in my callback function, which isn't being called back.