-
How to print scrolling form in vb6
I would like to print the contents of an MDI child form that is much larger than the screen size. When I use the statement
myform.printform
only the first part of the form is printed (essentially the part that would be captured by a screen capture). Is there any relatively straightforward way to print the entire form, e.g., over multiple pages?
Thanks in advance for your help.
-
Not that I'm aware.
Perhaps doing a printform - scroll - printform - scroll - etc?
-
Hack, Thanks for the suggestion. I tried that approach. Unfortunately the PrintForm method still printed only the top of the form.
-
Try this for the printing instead of Me.PrintForm
Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_MENU As Byte = &H12
Private Const VK_SNAPSHOT As Byte = &H2C
Private Const KEYEVENTF_KEYUP = &H2
Private Sub PrintTheForm()
Dim lWidth As Long, lHeight As Long
Clipboard.Clear
Call keybd_event(VK_MENU, 0, 0, 0)
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
DoEvents
Call keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0)
Call keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0)
Printer.Print
If Width > Printer.ScaleWidth Then
lWidth = Printer.ScaleWidth
lHeight = (Printer.ScaleWidth / Width) * Height
Else
lWidth = Width
lHeight = Height
End If
Printer.PaintPicture Clipboard.GetData, 0, 0, lWidth, lHeight
Printer.EndDoc
End Sub
This actually takes a pictures (or a "snapshot") of what is actually on the screen, so it should capture what is there after you do a scroll.
-
Looks like Hack's solved it for you, but i was going to suggest SavePicture(), to save the form's image to a file, and print it. Not sure whether it'd work with an MDI form's child though
-
 Originally Posted by CptNeutral
Looks like Hack's solved it for you, but i was going to suggest SavePicture(), to save the form's image to a file, and print it. Not sure whether it'd work with an MDI form's child though
That isn't a bad idea actually, with one potential "gotcha" and that is that SavePicture, which will save the contents of a picturebox control, is only going to save the contents in a bitmap format. This restricts the size to 1600x1200x24 bits.
This might not be an issue in this case, but it is something worth noting.
-
I didn't know that, thanks.
-
Both ideas seem to work. Thanks much!
-
Great!
CptNeutral's idea would be a good way to save a picture of the screen at any given point in time.
-
Similar Threads
-
By hmdaud@yahoo.co in forum VB Classic
Replies: 0
Last Post: 09-10-2007, 09:08 AM
-
Replies: 0
Last Post: 04-09-2001, 03:54 PM
-
By malikmehmood in forum Database
Replies: 0
Last Post: 11-20-2000, 06:12 AM
-
By crni in forum VB Classic
Replies: 0
Last Post: 10-14-2000, 08:37 PM
-
By chong in forum VB Classic
Replies: 0
Last Post: 03-30-2000, 03:48 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|