Results 1 to 3 of 3

Thread: Printing a Form

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Freeport
    Posts
    204

    Post

    I have try many way to print a form with control on it, on a letter size paper(8 x 11). Used Picturebox, even changing the resolution of the screen(this help some) but still it does not print like a doc. I use the form like a invoice. I need some help.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    Try using the StrechBlt API function:

    Public Declare Function StretchBlt _
    Lib "gdi32" Alias "StretchBlt" ( _
    ByVal hdc As Long, _
    ByVal x As Long, _
    ByVal y As Long, _
    ByVal nWidth As Long, _
    ByVal nHeight As Long, _
    ByVal hSrcDC As Long, _
    ByVal xSrc As Long, _
    ByVal ySrc As Long, _
    ByVal nSrcWidth As Long, _
    ByVal nSrcHeight As Long, _
    ByVal dwRop As Long) As Long

    Public Const SRCCOPY = &HCC0020

    Public Sub PrintForm(frm As Form, lngWidth As Long, lngHeight As Long)
    Printer.Print 'Importent! The printer object may not have an hDC if it hasn't been used.
    Call StrechBlt(Printer.hDC, 0, 0, lngWidth, lngHeight, _
    frm.hDC, 0&, 0&, frm.ScaleWidth, frm.ScaleHeight, SRCCOPY)
    Printer.EndDoc
    End Sub

    Copy the above code to a BAS module and call the PrintForm sub with the following arguments:
    frm = The Form you want to print
    lngWidth = The width of the printed output
    lngHeight = The height of the printed output

    Good luck!

    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com



  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Freeport
    Posts
    204

    Post

    Ok i'm just now starting to use module so help me out. My form name is frmMain and I use 8.5 X 11 paper.

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