Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

print screen

Posted on 2001-08-15
7
Medium Priority
?
351 Views
Last Modified: 2013-11-26
how do you make a program that automatically prints the screen(copies it to the clipboard) then pastes it into an image box?
0
Comment
Question by:short_fat_n_black
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 20

Expert Comment

by:hes
ID: 6389801
0
 
LVL 20

Expert Comment

by:hes
ID: 6389822
If you want the code to do a print screen, capture just the form, just the client area of the form let me know and I will post it.
0
 
LVL 2

Expert Comment

by:JanusFury
ID: 6390419
Here's something off the top of my head: (It'll require some API declarations from the API viewer.)

deskWnd = GetDesktopWindow
deskDC = GetDC(deskWnd)
BitBlt Picture1.hDC, 0, 0, Screen.Width \ Screen.TwipsPerPixelX, Screen.Height \ TwipsPerPixelY, deskDC, 0, 0, vbSrcCopy
ReleaseDC deskWnd, deskDC
deskDC = 0
deskWnd = 0

I'll make a full ver of the code when I get home.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:wsh2
ID: 6390613
<ping>
0
 
LVL 20

Expert Comment

by:hes
ID: 6390764
a ping from wsh2, havn't seen you on lately (until this week) :)
0
 
LVL 8

Accepted Solution

by:
glass_cookie earned 200 total points
ID: 6391093
Hi!

Here's a file for you over the net:

Download...
http://www.vb-helper.com/HowTo/formimg.zip

Descirption: Capture an image of a form in a PictureBox (2K)

I suppose you can change the picture box to tht of an image box.

That's it!

glass cookie : )
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6391300
Hi short_fat_n_black ,
   
To mimic the printscreen / take a snapshot of desktop:

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

Here is another version that Calling the Windows PrintScreen Function Using keybd_event:

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)

Private Const TheScreen = 0
Private Const TheForm = 1

Private Sub Command1_Click()
 'call the Windows keybd_event sub, passing the built-in
 'VB keyboard constant vbKeySnapshot (44) to the sub.

 'The four parameters for keybd_event are:
 'BYTE bVk           'virtual-key code
 'BYTE bScan         'hardware scan code
 'DWORD dwFlags      'flags specifying various function options
 'DWORD dwExtraInfo  'additional data associated with keystroke

 'The bScan parameter value determines what
 'to copy... passing 0 (TheScreen) copies
 'the screen, passing 1 (TheForm) copies the
 'active form.
  keybd_event vbKeySnapshot, TheForm, 0&, 0&
 
 'pause to let Windows update the clipboard
  DoEvents
 
 'retrieve the clipboard bitmap to the control (vbCFBitmap = 2)
  Image1.Picture = Clipboard.GetData(vbCFBitmap)

End Sub


Original Source: http://www.mvps.org/vbnet/code/bitmap/printscreenapi.htm

'Hope will help.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question