Real Software Forums
http://forums.realsoftware.com/

Print Screenshot / vb6 PrintForm equivalent
http://forums.realsoftware.com/viewtopic.php?f=21&t=34368
Page 1 of 1

Author:  dholland [ Wed Jun 23, 2010 1:02 pm ]
Post subject:  Print Screenshot / vb6 PrintForm equivalent

'--------------------------------------
' PRINT SCREEN MENU ITEM CODE
'--------------------------------------
Dim pict As Picture
Dim ps As PrinterSetup
Dim g As Graphics
Dim cc,c As Integer

//CREATE PICTURE OBJECT, SELF IS THE FORM WINDOW
pict = NewPicture(self.Width, self.Height, 32)

//CREATE A PICTURE OF THE CURRENT WINDOW
Self.DrawInto pict.Graphics, 0, 0

//THIS WINDOW LOOKS BEST PRINTED AS LANDSCAPE
//SO DEFAULT TO LANDSCAPE MODE
ps = New PrinterSetup
ps.Landscape =True

//PROMPT USER FOR PRINT SETTINGS AND PRINTER
If ps.pageSetupDialog then
g = OpenPrinterDialog(ps)
If g <> Nil Then
//PRINT THE SCREEN
c=g.Copies
For cc=1 To c
g.DrawPicture(pict, 0,0,ps.Width,ps.Height,0,0,pict.Width,pict.Height)
If cc=c Then
//STOP EXTRA BLANK PAGE FROM BEING PRINTED.
g=Nil
Else
g.NextPage
End If
Next cc
End If
End If

Author:  waveuponwave [ Mon Aug 09, 2010 2:32 am ]
Post subject:  Re: Print Screenshot / vb6 PrintForm equivalent

Thanks! Just what I was looking for! 8)

Author:  denisc [ Mon Aug 09, 2010 3:27 am ]
Post subject:  Re: Print Screenshot / vb6 PrintForm equivalent

Thanks for posting that, I'll need exactly that very shortly.

Regards
Denis

Author:  dholland [ Mon Aug 09, 2010 9:11 am ]
Post subject:  Re: Print Screenshot / vb6 PrintForm equivalent

Glad it helps. It was one of those things that took me longer than I thought it should to figure out.
Dave

Author:  DaveS [ Mon Aug 09, 2010 10:36 am ]
Post subject:  Re: Print Screenshot / vb6 PrintForm equivalent

This might be a tad bit better [my opinion]

For cc=1 To c
if c>1 then g.next page
g.DrawPicture(pict, 0,0,ps.Width,ps.Height,0,0,pict.Width,pict.Height)
Next cc
g=nil

Author:  dholland [ Mon Aug 09, 2010 10:45 am ]
Post subject:  Re: Print Screenshot / vb6 PrintForm equivalent

:) Thanks for the suggestion.
Dave

Author:  torrid [ Thu Feb 07, 2013 4:07 pm ]
Post subject:  Re: Print Screenshot / vb6 PrintForm equivalent

This works ok to get most of the window...

but I have a panel with a canvas that I draw a graph to... and this code just draws a big gray area.

So I'm guessing I have to capture that separately and manually draw it onto the canvas????

Same with a set of buttons that I draw on there inside a canvas area.

If so how do I draw this on top of the main screen capture???

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/