Home All Groups Group Topic Archive Search About
Author
23 Sep 2005 5:45 PM
Barry
Hi,

Could someone help me with regards to a Print Screen button?

Ideally, I'd like the Users to be able to click a button and then a
screen print, print to their default printer.

If possible, only a screen print of the current form?

Any help would be greatly appreciated

Many thanks

Barry

Author
23 Sep 2005 5:50 PM
Karl E. Peterson
Barry wrote:
> Ideally, I'd like the Users to be able to click a button and then a
> screen print, print to their default printer.
>
> If possible, only a screen print of the current form?

How To Capture and Print the Screen, a Form, or Any Window
http://support.microsoft.com/kb/q161299/

--
Working Without a .NET?
http://classicvb.org/petition
Author
23 Sep 2005 6:03 PM
Barry
Thanks Karl  - that's just what I'm looking for.

Barry
Author
23 Sep 2005 6:08 PM
Karl E. Peterson
Barry wrote:
> Thanks Karl  - that's just what I'm looking for.

You probably wouldn't believe how I found it, either?

http://www.google.com/search?q=screen+capture+vb+site%3Amicrosoft.com

;-)
--
Working Without a .NET?
http://classicvb.org/petition
Author
23 Sep 2005 6:34 PM
Barry
LOL!

Guess I should stop being lazy and look first! ;-)

Although, there is nothing worse then searching Google for 30 mins and
finding nothing and then posting a question and bang - 5 mins later
you've got your answer.

Have a good weekend!
Author
23 Sep 2005 8:08 PM
Karl E. Peterson
Barry wrote:
> LOL!
>
> Guess I should stop being lazy and look first! ;-)
>
> Although, there is nothing worse then searching Google for 30 mins and
> finding nothing and then posting a question and bang - 5 mins later
> you've got your answer.

To be fair, I knew the article was there.  I've referred dozens (hundreds?) of folks
to it over the years.

> Have a good weekend!

You too...  :-)
--
Working Without a .NET?
http://classicvb.org/petition
Author
23 Sep 2005 6:18 PM
Mike Williams
"Barry" <barry.ocon***@singers.co.im> wrote in message
news:1127497515.792933.60980@g44g2000cwa.googlegroups.com...

> Could someone help me with regards to a Print Screen button?
> Ideally, I'd like the Users to be able to click a button and then a
> screen print, print to their default printer.

There are almost as many ways of getting a bitmap of the screen (or of a
window) as there are ways of . . . erm . . . "gettin' it away" in the Kama
Sutra ;-)

Here is some code (no apologies for it being a bit "rough and ready") that
will allow you to get a bitmap of either the entire Form or just its client
area. Once you've got the bitmap you can easily print it using the VB
PaintPicture method.

Mike

Option Explicit
Private Declare Function GetDC Lib "user32" _
  (ByVal hwnd As Long) As Long
Private Declare Function GetWindowDC Lib "user32" _
  (ByVal hwnd As Long) As Long
Private Declare Function BitBlt Lib "gdi32" _
  (ByVal hDestDC As Long, _
  ByVal x As Long, ByVal y As Long, _
  ByVal nWidth As Long, ByVal nHeight As Long, _
  ByVal hSrcDC As Long, _
  ByVal xSrc As Long, ByVal ySrc As Long, _
  ByVal dwRop As Long) As Long

Private Sub Command1_Click()
Dim oldscale As Long
oldscale = Me.ScaleMode
Me.ScaleMode = vbPixels
'
' the Form's client area
'Picture1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
'Picture1.Cls ' ensure picbox Image property is properly resized
'DoEvents
'BitBlt Picture1.hDC, 0, 0, Me.ScaleWidth, Me.ScaleHeight, _
  GetDC(Me.hwnd), 0, 0, vbSrcCopy
'
' the entire Form
Picture1.Move 0, 0, Me.ScaleX(Me.Width, vbTwips, vbPixels), _
  Me.ScaleY(Me.Height, vbTwips, vbPixels)
Picture1.Cls ' ensure picbox Image property is properly resized
DoEvents
BitBlt Picture1.hDC, 0, 0, Me.ScaleX(Me.Width, vbTwips, _
  vbPixels), Me.ScaleY(Me.Height, vbTwips, vbPixels), _
  GetWindowDC(Me.hwnd), 0, 0, vbSrcCopy
'
Me.ScaleMode = oldscale
'
SavePicture Picture1.Image, "c:\myformpic.bmp"
Caption = Me.ScaleWidth
End Sub

Private Sub Form_Load()
'Me.ScaleMode = vbPixels
Picture1.Visible = False
Picture1.AutoRedraw = True
Picture1.BorderStyle = vbBSNone
End Sub
Author
23 Sep 2005 6:35 PM
Barry
Thanks for the reply Mike..... interesting comparision by the way -
I'll er take a look at that!

;-)