Announcement

Collapse
No announcement yet.

Vertical Text Printing...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jules Marchildon
    replied
    Borje, your like a DJ, the Hits just keep ah comming! Your drawers must
    be overflowing? Thank you!

    Mark, just a note, it is always wise to restore the origional font
    so that other parts of your code that might be using it won't will
    function correctly.

    Regards, Jules

    ------------------

    Leave a comment:


  • Borje Hagsten
    replied
    Mark, now that you mention it - DeleteObject SelectObject(hDC, newfont)
    sure looks better, even if DeleteObject hFont actually seems to be the
    same thing - they both delete the same object (just checked). I changed
    the code above to look like:
    Code:
      hDC = getDc(hWnd&)
        newfont = selectobject(hDC, hfont)
      
        GetClientRect hWnd&, rc : rc.nBottom = rc.nBottom - 40
        FillRect hDC, rc, GetStockObject(%LTGRAY_BRUSH)        '<- Erase background
     
        SetBkColor   hDC, RGB(192, 192, 192)
        SetTextColor hDC, RGB(128,   0, 128)
     
        TextOut hDC, x&, y&, BYVAL STRPTR(Txt$), LEN(Txt$)     '<- Print text
     
        DeleteObject SelectObject(hDC, newfont)
      ReleaseDC hWnd&, hDC
    Regarding exact scaling: Get and use the printer's physical
    PageWidth and PageHeight settings. You can never get a 100%
    perfect view, but it will be good enough. I have just posted
    some printer code to the source code section that may, or may
    not, help you out..


    ------------------

    Leave a comment:


  • Michael Meeks
    replied

    I have to agree with Frank

    Don Dickerson's DDOC comes with complete source-code and
    should do just about anything you'd want with your printer!

    Have a great day!



    ------------------
    mwm

    Leave a comment:


  • Frank Kelley
    Guest replied
    If you would like to avoid all the hassles with printing through
    the Windows API, get a copy of ddoc by Don Dickinson. It will
    take care of vertical printing (as well as diagonal), printing
    at any angle, and has a document viewer built right in. The
    best $29.95 I ever spent!

    Frank

    ------------------

    Leave a comment:


  • mark smit
    Guest replied
    Thank you both!

    Borje, I was wondering about the use of SelectObject in you're
    RotateText function. I noticed that you did not select the old
    font back into the DC before you called DeleteObject. I thought
    you had to select the old object back into the DC before you could
    delete the new object?

    What do know about exact scaling in a window. I wanted to show
    a preview of a 8.5" x 11" sheet of paper. The problem is that I
    can't seem to find out how to get the "REAL" DPI of what ever
    monitor my program runs on... I posted this question in the forum
    but I guess it wouldn't hurt to mention it here to...

    ------------------
    Cheers

    Leave a comment:


  • Jules Marchildon
    replied
    Yep! Had the same thing in my drawer's.

    Code:
    '---
        CASE %WM_CREATE
     
            '---
            hDC= GetDC (hWnd)
            ghMyFont = CreateFont( _
              20,0, _   'height,width(default=0)
              900,0, _  'escapement(angle),orientation (1/10 degree)
              400, _    'weight (default=0,normal=400,bold=700)
              %FALSE, _ 'Italic
              %FALSE, _ 'Underline
              %FALSE, _ 'StrikeThru
              %ANSI_CHARSET, %OUT_CHARACTER_PRECIS, _
              %CLIP_DEFAULT_PRECIS, %PROOF_QUALITY, _
              %FIXED_PITCH Or %FF_MODERN,"Courier New" )
     
    '---
        CASE %WM_PAINT
     
     
            '*Paint something so we can see the window
            GetClientRect hWnd,rc
            hdc = BeginPaint(hWnd, ps)
            CALL SelectObject(hDC, CreateSolidBrush(RGB(0, 0, 255)))
            CALL Rectangle(hDC,       _
                           rc.nLeft,  _
                           rc.nTop,   _
                           rc.nRight, _
                           rc.nBottom)
     
             
            'Add some text with custom font,
            hOldFont& = SelectObject(hDC,ghMyFont)
            Dim sz_Line1  As Asciiz*40  '
            sz_Line1  =  "Hello World"
            SetTextColor hDC, Rgb(255,0,0) 'RED
            SetBkColor   hDC, Rgb(0,0,255)
            TextOut hDC, 10, 200 , sz_Line1, Len(sz_Line1)
            SelectObject hDC,hOldFont&
            CALL EndPaint(hWnd, ps)
            Function = 0
    HTH
    Jules

    ------------------

    Leave a comment:


  • Borje Hagsten
    replied
    Had the following in one of my drawers. Think it's ok, so maybe
    it can be of some help to you.
    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Simple Font rotation in PB by Borje Hagsten, July 2000
    ' Public Domain
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    DECLARE SUB RotateText(BYVAL hWnd&, BYVAL degr%, BYVAL Txt$, BYVAL x&, BYVAL y&)
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Callback for dialog and controls
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION DlgCallback()
      SELECT CASE CBMSG
     
         CASE %WM_INITDIALOG
            STATIC Angle AS INTEGER
            Angle = 315
     
         CASE %WM_COMMAND
            SELECT CASE CBCTL
               CASE %IDOK
                  Angle = Angle + 45 : IF Angle > 360 THEN Angle = 45
                  InvalidateRect CBHNDL, BYVAL %NULL, 0 : UpdateWindow CBHNDL
     
               CASE %IDCANCEL
                  DIALOG END CBHNDL, 1
            END SELECT
            
         CASE %WM_PAINT
            RotateText CBHNDL, Angle, "Hello World!", 110, 110
            FUNCTION = 0
     
      END SELECT
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Create dialog and controls
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION PBMAIN () AS LONG
      LOCAL hDlg AS LONG
      DIALOG NEW 0, "PB Rotate text sample",,, 150, 175, %WS_SYSMENU, 0 TO hDlg
     
      CONTROL ADD BUTTON, hDlg, %IDOK,     "Rotate", 15, 140, 60, 14
      CONTROL ADD BUTTON, hDlg, %IDCANCEL, "E&xit",  75, 140, 60, 14
     
      DIALOG SHOW MODAL hDlg CALL DlgCallback
     
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Rotate text in any angle (degr%) - x and y are Left and Top position of text
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    SUB RotateText(BYVAL hWnd&, BYVAL degr%, BYVAL Txt$, BYVAL x&, BYVAL y&)
     
      LOCAL lFont AS LOGFONT, rc AS RECT
      LOCAL hDc AS LONG, hfont AS LONG, newfont AS LONG
      IF degr% = 0 THEN degr% = 360
     
      lFont.lfescapement  = degr% * 10                         '<- Set Angle
      lFont.lforientation = degr% * 10
      lFont.lfHeight = -18                                     '<- Font Size
      lFont.lfWeight = %FW_BOLD                                '<- Bold
      lFont.lfItalic = %FALSE
      lFont.lfCharSet = %ANSI_CHARSET
      lFont.lfOutPrecision = %OUT_TT_PRECIS
      lFont.lfClipPrecision =%CLIP_DEFAULT_PRECIS
      lFont.lfQuality = %DEFAULT_QUALITY
      lFont.lfPitchAndFamily = %FF_DONTCARE
      lFont.lfFaceName = "Times New Roman"                     '<- Font Name
     
     'create font and assign handle to a variable
      hFont = CreateFontIndirect(BYVAL VARPTR(lFont))
     
      hDC = getDc(hWnd&)
        newfont = selectobject(hDC, hfont)
     
        GetClientRect hWnd&, rc : rc.nBottom = rc.nBottom - 40
        FillRect hDC, rc, GetStockObject(%LTGRAY_BRUSH)        '<- Erase background
     
        SetBkColor   hDC, RGB(192, 192, 192)
        SetTextColor hDC, RGB(128,   0, 128)
     
        TextOut hDC, x&, y&, BYVAL STRPTR(Txt$), LEN(Txt$)     '<- Print text
     
        DeleteObject SelectObject(hDC, newfont)
      ReleaseDC hWnd&, hDC
     
    END SUB

    [This message has been edited by Borje Hagsten (edited July 05, 2000).]

    Leave a comment:


  • Eric Pearson
    replied
    You need to create a font with the proper "Escapement" and "Orientation" values. See the CreateFont API for details.

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • mark smit
    Guest started a topic Vertical Text Printing...

    Vertical Text Printing...

    Hello,

    Could anybody give me some pointers on how to print text out on
    a device context verticaly?

    !
    d
    l
    r
    o
    W

    ,
    o
    l
    l
    e
    H

    That is kind of what I ment by verticaly but I would also like the
    letters to be turned CCW 90deg. Any ideas?

    ------------------
    Cheers

    [This message has been edited by mark smit (edited July 05, 2000).]
Working...
X