Results 1 to 4 of 4

Thread: EnumFontFamProc not being CalledBack by EnumFontFamilies

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297

    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

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    Sorry,

    Missed the attachment:
    Attached Files Attached Files

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    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:
    1. Dim f As FontFamily
    2.         For Each f In FontFamily.Families
    3.             Console.WriteLine(f.Name)
    4.         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]

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    Sysop,

    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.

    Thanks for the message though!

    --Ben

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width