Print Screen command from VB6 
Author Message
 Print Screen command from VB6

I want to issue a Print Screen command from VB6. I found the API once
but can I find it now? Nope :-(

Help would be appreciated.

TIA.

Regards.

--
Martin Trump



Sat, 11 Sep 2004 02:56:26 GMT  
 Print Screen command from VB6
Use the following:

Option Explicit
Private Declare Sub keybd_event Lib "User32" _
  (ByVal bVk As Byte, ByVal bScan As Byte, _
  ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const VK_SNAPSHOT As Byte = 44

Private Sub Command1_Click()
Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
End Sub

If you want to copy the currently active window (rather than the entire
screen) then change the first parameter from a 1 to a zero.

By the way, this stuff dumps the screen to the Windows clipboard, just like
the PrtScreen key does (as you obviously already know). Sometimes, this can
be a problem. If you would rather leave the Clipboard alone (which I would
advise) and instead dump the screen directly to a hidden Autoredraw Picture
Box then you can get a handle to the Screen and use BitBlt to do it.

Mike


Quote:
> I want to issue a Print Screen command from VB6. I found the API once
> but can I find it now? Nope :-(

> Help would be appreciated.

> TIA.

> Regards.

> --
> Martin Trump



Sat, 11 Sep 2004 03:47:52 GMT  
 Print Screen command from VB6
Take your pick. The OLE and printscreenvars methods allows you to print the
screen or any window by specifying a hwnd.

http://www.mvps.org/vbnet/code/bitmap/printscreenapi.htm
http://www.mvps.org/vbnet/code/bitmap/printscreen.htm
http://www.mvps.org/vbnet/code/bitmap/printscreenvars.htm
http://www.mvps.org/vbnet/code/bitmap/printscreenole.htm

--

Randy Birch
MVP Visual Basic

http://www.mvps.org/vbnet/

Please respond only to the newsgroups so all can benefit.

*** If you call the Sleep API in Bill's latest, will it have .NET dreams?
***


Quote:
> I want to issue a Print Screen command from VB6. I found the API once
> but can I find it now? Nope :-(

> Help would be appreciated.

> TIA.

> Regards.

> --
> Martin Trump



Sat, 11 Sep 2004 06:43:08 GMT  
 Print Screen command from VB6

smill.freeserve.co.uk> writes

Quote:
>By the way, this stuff dumps the screen to the Windows clipboard, just like
>the PrtScreen key does (as you obviously already know). Sometimes, this can
>be a problem. If you would rather leave the Clipboard alone (which I would
>advise) and instead dump the screen directly to a hidden Autoredraw Picture
>Box then you can get a handle to the Screen and use BitBlt to do it.

Mike, many thanks. Randy too, your posting has just appeared here.
That's given me a start and I'll investigate. I've made some progress
using a manual Print Screen.

I looked up BitBlt in the Api Guide and in Examples found all sorts of
funny things I just don't understand such as:-

Const FW_DONTCARE = 0
Const FW_THIN = 100
Const FW_EXTRALIGHT = 200
Const FW_LIGHT = 300
Const FW_NORMAL = 400
...

and

Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long,
ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal
nBkMode As Long) As Long
Private Declare Function GetSysColorBrush Lib "user32" (ByVal nI
...

At that stage my legs went wobbly and I broke into a cold sweat :-)

Regards.

--
Martin Trump



Sat, 11 Sep 2004 06:58:22 GMT  
 Print Screen command from VB6

Quote:
> Mike, many thanks. Randy too, your posting has just appeared here.
> That's given me a start and I'll investigate. I've made some progress
> using a manual Print Screen.
> snip <
> At that stage my legs went wobbly and I broke into a cold sweat :-)

Don't worry, Martin. It's dead easy really. The links posted by Randy will
provide you with working code. I would suggest using the first link he
posted rather than the others. There is no need to mess about with the OLE
stuff. Post again if your legs are still wobbly and you need some working
code.

Mike



Sat, 11 Sep 2004 07:19:03 GMT  
 Print Screen command from VB6
Hi Martin ...

<g>

The FW_* constants are for working with logical fonts, so don't apply to
BitBlt in the context of a printscreen.(FW = Font Weight, and in working
with logical fonts you tell the system, on creating the font, how precise it
must match your input parameters, ie match weight as thin, ultrathin, bold,
extrabold, or 'don't care' .. just give me the closest matching font). IOW,
forget them.

Ditto SetBkMode (Set Back Mode - background mix mode of the specified device
context. The background mix mode is used with text, hatched brushes, and pen
styles that are not solid lines), and MulDiv (Multiple Divide - multiplies
two 32-bit values and then divides the 64-bit result by a third 32-bit
value. The return value is rounded up or down to the nearest integer.)
Again, those are used in indicating how the output will render (the stroke)
and in calculating point sizes for logical fonts.

--

Randy Birch
MVP Visual Basic

http://www.mvps.org/vbnet/

Please respond only to the newsgroups so all can benefit.

*** If you call the Sleep API in Bill's latest, will it have .NET dreams?
***


Quote:

> smill.freeserve.co.uk> writes
> >By the way, this stuff dumps the screen to the Windows clipboard, just
like
> >the PrtScreen key does (as you obviously already know). Sometimes, this
can
> >be a problem. If you would rather leave the Clipboard alone (which I
would
> >advise) and instead dump the screen directly to a hidden Autoredraw
Picture
> >Box then you can get a handle to the Screen and use BitBlt to do it.

> Mike, many thanks. Randy too, your posting has just appeared here.
> That's given me a start and I'll investigate. I've made some progress
> using a manual Print Screen.

> I looked up BitBlt in the Api Guide and in Examples found all sorts of
> funny things I just don't understand such as:-

> Const FW_DONTCARE = 0
> Const FW_THIN = 100
> Const FW_EXTRALIGHT = 200
> Const FW_LIGHT = 300
> Const FW_NORMAL = 400
> ...

> and

> Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long,
> ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
> Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal
> nBkMode As Long) As Long
> Private Declare Function GetSysColorBrush Lib "user32" (ByVal nI
> ...

> At that stage my legs went wobbly and I broke into a cold sweat :-)

> Regards.

> --
> Martin Trump



Sat, 11 Sep 2004 07:28:18 GMT  
 Print Screen command from VB6


Quote:
><g>

>The FW_* constants are for working with logical fonts, so don't apply to

Thanks again. With the good help I'm getting here I feel sure I'll reach
a solution to my prob.

Regards.

--
Martin Trump



Sat, 11 Sep 2004 07:49:20 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. VB6 Print Screen Function....

2. Help with Win 95 screen saver command line - command line.zip [1/1]

3. Q: Printing to screen using multi fonts (ie, print preview)

4. Print commands and multiline print output??

5. Printing problems when repeating to print the same report from VB6.0

6. command bar vs. screen resolution

7. Screen Problems when doing a command line import.

8. Echo to Dos Command Screen

9. Splash Screen and Animated Command Buttons...

10. Any commands to clear the debug screen

11. Screen Saver commands ?

12. Visio in VB6 via OLE = long delay before screen updates

 

 
Powered by phpBB® Forum Software