Results 1 to 5 of 5

Thread: AaronYoung and Party Help!!

  1. #1

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

    Post

    I have been trying to use a form as a invoice but when I go and Print it out it does not print the full page. I have try many of a different way's. I have try changing the screen resolution and the lates was given to me by Jaocim


    Declare Function StretchBlt Lib "gdi32" (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 PrintFrm(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 StretchBlt(Printer.hdc, 0, 0, lngWidth, lngHeight, _
    frm.hdc, 0&, 0&, frm.ScaleWidth, frm.ScaleHeight, SRCCOPY)
    Printer.Print
    Printer.EndDoc
    End Sub

    Private Sub Command1_Click()
    PrintFrm Form1, 8, 11

    End Sub
    Can you help me

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Try:
    Add a Picturebox to your Form..
    Code:
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
    Private Const SRCCOPY = &HCC0020
    
    Private Sub Command1_Click()
        Dim W As Integer
        Dim H As Integer
        Dim X As Integer
        Dim Y As Integer
        Dim oX As Single
        Dim oY As Single
        
        oX = Left
        oY = Top
        W = 400
        H = 400
        Picture1.Move 0, 0, ScaleWidth, ScaleHeight
        For Y = 0 To Int(ScaleHeight / H) + 1
            For X = 0 To Int(ScaleWidth / W) + 1
                Move ScaleX(-X * W, vbPixels, vbTwips), ScaleY(-Y * H, vbPixels, vbTwips)
                DoEvents
                BitBlt Picture1.hDC, X * W, Y * H, W, H, hDC, X * W, Y * H, SRCCOPY
            Next
        Next
        Move oX, oY
        Printer.PaintPicture Picture1.Image, 0, 0
        Printer.EndDoc
    End Sub
    
    Private Sub Form_Load()
        ScaleMode = vbPixels
        With Picture1
            .Visible = False
            .BorderStyle = vbBSNone
            .ScaleMode = vbPixels
            .AutoRedraw = True
        End With
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net


    [This message has been edited by Aaron Young (edited 12-01-1999).]

  3. #3

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

    Post

    I made a form place a picturebox on it then added some control in the picturebox.Place a button on the form and paste the code in and try it. It still only print a small picture box in the top left of the page. It does not use the full page

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Don't place any Controls in the Picturebox, it's used Soley for Copying the Form Image in its Entirity and Transferring it to the Printer.

    If your problem is that it's printing the whole Form, just not filling the whole page, use the Extra Width and Height Parameters of the PaintPicture Method to Strech the Picturebox Image to Fit the Whole Page.
    NB. doing so may result in any Text being distorted.


    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  5. #5

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

    Post

    Thanks Aaron I believe that gone to work.

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