?
Solved

Printing Logical Fonts

Posted on 1998-08-24
2
Medium Priority
?
192 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
[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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

801 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