Solved

Printing Logical Fonts

Posted on 1998-08-24
2
187 Views
Last Modified: 2013-12-02
I have created a logical font using WIN32 APIs.  I can output it on a picture box using the "textout" function.
What I need is to convert this to a metafile so I can print it or print it as is.  Is there any way to do this in VB?
0
Comment
Question by:janim
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1430802
Here is a function I wrote to print rotated text in a picture box or on the printer. You could modify a bit this function and use it.

Public Sub RotateText(lnghDC As Long, ByVal strText As String, ByVal intAngle As Integer, ByVal lngX As Long, ByVal lngY As Long, fntText As StdFont)
  ' Comments  : Draws rotated text onto a form or picture box
  ' Parameters: lnghDC - hdc of form, picture, usercontrol etc
  '             strText - text to print
  '             intAngle - value between 0 and 360
  '             lngX - X position to print, in pixels
  '             lngY - Y position to print, in pixels
  '             fntText - font object. May be an object of type
  '             'stdFont', or the font property of an existing
  '             control or form
  ' Returns   : Nothing
  '
  Dim lnghNewFont       As Long
  Dim lnghOrigFont      As Long
  Dim lngHeight         As Long
  Dim lngResult         As Long
 
  On Error GoTo PROC_ERR
 
  ' take dimension information from passed font
  With fntText
 
    ' calculate height from font size
    lngHeight = -MulDiv(.Size, GetDeviceCaps(lnghDC, LOGPIXELSY), 72)
 
    ' create font with specified attributes
    lnghNewFont = CreateFont( _
      nHeight:=lngHeight, _
      nWidth:=0, _
      nEscapement:=intAngle * 10, _
      nOrientation:=intAngle * 10, _
      fnWeight:=.Weight, _
      fdwItalic:=.Italic, _
      fdwUnderline:=.Underline, _
      fdwStrikeOut:=.Strikethrough, _
      fdwCharSet:=.Charset, _
      fdwOutputPrecision:=0, _
      fdwClipPrecision:=CLIP_LH_ANGLES, _
      fdwQuality:=0, _
      PitchAndFamily:=0, _
      lpszFace:=.Name)
    End With
   
  ' Select the new font
  lnghOrigFont = SelectObject(lnghDC, lnghNewFont)
 
  ' Draw the text into the device context. For more control consider
  ' using the DrawText API
  lngResult = TextOut(lnghDC, lngX, lngY, strText, Len(strText))
 
  ' Restore the original font
  lnghNewFont = SelectObject(lnghDC, lnghOrigFont)
 
  ' Cleanup
  DeleteObject lnghNewFont

PROC_EXIT:
  Exit Sub

PROC_ERR:
  Resume PROC_EXIT

End Sub

0
 

Author Comment

by:janim
ID: 1430803
i already did this textout function... what i need is to directly print it to the printer device... thanks anyway!  the solution was just simple... i just need to have a print command before doing the textout and print.enddoc to end the printing job.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now