Results 1 to 4 of 4

Thread: Printing a form

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    60
    I know most of you have come to this thread expecting me to ask you how do i print a form, well i'm not quite that dense.

    I have a form with an image on it (A4 size), which is an image of a table, i have labels over it so that i can dynamically alter the data on it. This form a datasheet for my program. When i come to print it out it cuts of the bottom (where the screen would cut it off if it were shown (which it is not, it is just loaded)). Has any one got any ideas, i am completely stumped. The size of the form has been set through code to be the exact size of the image, when i check the size of the form after it has printed it is still correct???

    Please HELP!
    Grant French
    -----------------------------------------------
    E-Mail: [email protected]
    ICQ: 33122184

  2. #2
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    http://www.vb-world.net/controls/printpreview.html

    The printform method always clips the formto the screen size

    The option is to physically draw everything on the printer object or use an ocx

    DocZaf
    {;->

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    60

    No OCX's please

    I want this prog to be light weight and i dont really want a print preview, i just want it to print, could you expand a bit more on your other idea of drawing it all to the printer object please.

    Thanks for the help, it is appreaciated,
    Grant French
    -----------------------------------------------
    E-Mail: [email protected]
    ICQ: 33122184

  4. #4
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    Okay,

    Here is a portion of the print routine that is used to MANUALLY redraw all the controls on the sample application form ONTO the PRINTER object:

    Code:
    Private Sub PrintFrm(PFrm As Form)
        ' Declare local variables.
        Dim CtlCnt
        ' Change the mouse pointer to the hourglass.
        PFrm.MousePointer = 11
        ' Set the font size for the Printer object.
        Printer.FontSize = 8.25
        ' Move the (0, 0) coordinates of the Printer object to center the
        ' form in the page.
        Printer.ScaleLeft = -((Printer.Width - PFrm.Width) / 2)
        Printer.ScaleTop = -((Printer.Height - PFrm.Height) / 2)
        ' Draw a box that represents the outline of the form.
        DrawWidth = 2
        Printer.Line (0, 0)-Step(PFrm.Width, PFrm.Height), , B
        ' Print Title bar on Printer object.
        Printer.Line (0, BarHgt)-Step(PFrm.Width, 0)
        Printer.CurrentX = (PFrm.Width - Printer.TextWidth("TimeCard")) / 2
        Printer.CurrentY = (BarHgt - Printer.TextHeight("TimeCard")) / 2
        Printer.Print "TimeCard"
        ' Move the (0, 0) coordinates of the Printer object so that it
        ' coincides with the (0, 0) coordinates of the form's client area
        ' by moving down a distance equal to the height of the Title bar
        ' and the Menu bar.
        SetClientPrintOrigin Card
        ' Use the Line method to redraw the lines and boxes displayed on the
        ' form on the Printer object.
        LinesOnPrinter
        ' Find and print the following controls if they are on the form...
        For CtlCnt = 0 To PFrm.Controls.Count - 1
            ' If command button...
            If TypeOf PFrm.Controls(CtlCnt) Is CommandButton Then
                DrawCmd PFrm.Controls(CtlCnt)
            ' If image control...
            ElseIf TypeOf PFrm.Controls(CtlCnt) Is PictureBox Then
                DrawPic PFrm.Controls(CtlCnt)
            ' If label...
            ElseIf TypeOf PFrm.Controls(CtlCnt) Is Label Then
                DrawLbl PFrm.Controls(CtlCnt)
            End If
        Next CtlCnt
        ' Send contents of Printer object to printer.
        Printer.EndDoc
        ' Change the mouse pointer back to default.
        PFrm.MousePointer = 0
    End Sub
    As the sample application consists of three forms , it is a bit too big to post here, so i will email the sample to you and you can try it and maybe understand better what i am trying to say, i know my choice of words is not always the best possible, and maybe seeing it in action may help you to understand better what i'm trying to say.

    DocZaf
    {;->

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