Printing Multiple Forms in VB4If you could tell me how to print multiple forms on a single page it would be greatly appreciated.
Thanks.
From: Pete Webb
Email: fox@connect.reach.net
I would suggest that you instead write some code to interpret the objects on the form into a series of graphics methods that you can send to the printer, consider the following code.
Dim iNum As Integer
Printer.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), 0, B
For iNum = 0 To Me.Controls.Count - 1
Printer.FontName = Me.Controls(iNum).FontName
Printer.FontSize = Me.Controls(iNum).FontSize
Printer.FontBold = Me.Controls(iNum).FontBold
Printer.FontItalic = Me.Controls(iNum).FontItalic
Printer.FontUnderline = Me.Controls(iNum).FontUnderline
If TypeOf Me.Controls(iNum) Is CommandButton Then
Printer.Line (Me.Controls(iNum).Left,Me.Controls(iNum).Top)-
(Me.Controls(iNum).Width,Me.Controls(iNum).Height), 0, B
Printer.CurrentX = Me.Controls(iNum).Left + (Printer.TextWidth
(Me.Controls(iNum).Caption) \ 2)
Printer.CurrentY = Me.Controls(iNum).Top + (Printer.TextHeight
(Me.Controls(iNum).Caption) \ 2)
Printer.Print Me.Controls(iNum).Caption
ElseIf TypeOf Me.Controls(iNum) Is OptionButton Then
Printer.Circle (Me.Controls(iNum).Left + 60,Me.Controls(iNum).Left + 600), 100
If Me.Controls(iNum).Value <> 0 Then
Printer.FillColor = 0
Printer.Circle (Me.Controls(iNum).Left + 60,Me.Controls(iNum).Left + 600), 50
End If
Printer.CurrentX = Me.Controls(iNum).Left + 10
Printer.CurrentY = Me.Controls(iNum).Top + 10
Printer.Print Me.Controls(iNum).Caption
End If
Next iNum
Printer.EndDoc
Essentially we iterate through all the objects on the form and interpret them as a series of commands for the printer. This code is a quick draft, and some of the positioning is off, but it should give you the idea. Just deal with one type of control at a time, when you get the rendering of each control working it doesn't matter how many you have on the form, they will still work.
This may not give you the prettiest output, but it will basically work, also you can parse you second form by simply adding the first form's ScaleHeight to all the vertical positioning of the second form.
Good Luck, I hope this helps you achieve what you need to do.