Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I print more than I can see on a form? 1

Status
Not open for further replies.

Az43

Computer
Dec 11, 2002
4
GB
Is it possible to print the entire contents of a form including that which cannot be seen (because it is off to one side, not because it's invisible)?
If not, is it possible to print a picture box and it's contents including those that do not fit on the form?

Any help/advice would be greatly appreciated as I need to do this for part of my A-Level project.

-Az43-
 
Replies continue below

Recommended for you

Maybe this will do the job:
Put this code in Form module witch Form you want to print!



Private Sub Command1_Click()

'dim ......... put here declarations ......

'********************** Printing a limit box (only for probe)****************

Printer.ScaleMode = vbCentimeters
Printer.Orientation = 2 ' or 1

HorizontalMargin = (29.7 - Printer.ScaleWidth) / 2
VerticalMargin = (21 - Printer.ScaleHeight) / 2

HorizontalMargin = HorizontalMargin ' in my case!!!!!
VerticalMargin = 1 + VerticalMargin ' never mind

Printer.Print "";

Printer.Line (HorizontalMargin, VerticalMargin)-(29.7 - HorizontalMargin - 1, 21 - VerticalMargin), RGB(0, 0, 0), B

'*************************************************
Printer.ScaleMode = 1

Dim c As Control 'use c as the generic control object

For Each c In Controls

If TypeOf c Is Label Then ' for all labels

Printer.FontName = c.FontName
Printer.FontSize = c.FontSize
Printer.FontBold = c.FontBold
Printer.FontItalic = c.FontItalic
Printer.FontUnderline = c.FontUnderline
Printer.FontStrikethru = c.FontStrikethru
Printer.ForeColor = c.ForeColor


Printer.CurrentX = c.Left
Printer.CurrentY = c.Top

Printer.Print c.Caption;

End If

If TypeOf c Is TextBox Then 'for all textboxes

Printer.FontName = c.FontName
Printer.FontSize = c.FontSize
Printer.FontBold = c.FontBold
Printer.FontItalic = c.FontItalic
Printer.FontUnderline = c.FontUnderline
Printer.FontStrikethru = c.FontStrikethru
Printer.ForeColor = c.ForeColor


Printer.CurrentX = c.Left
Printer.CurrentY = c.Top
Printer.Print c.Text;

End If

If TypeOf c Is PictureBox Then 'for all PictureBoxes

Printer.CurrentX = c.Left
Printer.CurrentY = c.Top

c.AutoSize = True
c.Refresh
c.AutoSize = False

Printer.PaintPicture c.Picture, c.Left, c.Top

End If

If TypeOf c Is Image Then 'for all Images

Printer.CurrentX = c.Left
Printer.CurrentY = c.Top

Printer.PaintPicture c.Picture, c.Left, c.Top

End If

If TypeOf c Is Line Then 'for all lines

'make requisted lines properties equal with Printer object properties.......
Printer.Line (c.X1, c.Y1)-(c.X2, c.Y2)
End If

' And so on:
'first put "if TypeOf c Is AnyControl Then"
'then make the properties of AnyControl equal with Printer object properties
'and print. ....

Next c

Printer.EndDoc
End Sub
 
Many thanks for the solution. A minor tweak to account for if no image was present in the image box and this worked a treat!
 
Try using the PrintForm Method.
The syntax is as follows:

[form.]PrintForm

If you omit the form name, Visual Basic prints the current form. PrintForm prints the entire form, even if part of the form is not visible on the screen. If a form contains graphics, however, the graphics print only if the form’s AutoRedraw property is set to True. When printing is complete, PrintForm calls the EndDoc method to clear the printer.

 
You are Wright Jonathan, but there is big difference in printing quality.Only printing pictures are the same quality.
 
Thank you for the suggestions, however using the printform method will only print the contents of the from that is currently visible.
My problem was that I wanted to print controls that were off the edge of a form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top