Solved

PrintScreen

Posted on 1998-06-13
8
462 Views
Last Modified: 2008-03-06
hi guys!
I was wondering is there any way to take a picture of the screen into the clipboard , as i do
when i press PrintScreen button?(without using c written dll)
thnx ,Pavel
0
Comment
Question by:Pavel040997
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1463230
Why don't you go to www.download.com and look for a Screen capture ActiveX?

There are a few to choose from

0
 
LVL 1

Expert Comment

by:sirigere
ID: 1463231
I think you can use windows API call to capture/grab the screen. If you are interested I can get you the exact API to use. But I didn't get what you mean by not using C written DLL
0
 
LVL 1

Author Comment

by:Pavel040997
ID: 1463232
Yes sirigere plz tell me the exact API !
thnx ,pavel
0
Technology Partners: 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 1

Expert Comment

by:MAVERICK
ID: 1463233
Since I attempted your question I saw in a book "VB5 developers handbook" just what you wanted, The APIs and all! You may consider buying or borrowing the book. It is a good book and Im considering buying the book myself! I was browsing a friends copy

0
 
LVL 1

Expert Comment

by:sirigere
ID: 1463234
To pavel
To do your task you got to use the following set of APIs
1. GetDesktopWindow  to get the handle to the screen
for the declaration you can do cut and paste from the API text viewer. Using this window you will get the handle to screen
2.Use GetDC to convert handle to device context
3. Use BitBlt to get the copy of entire screen
4.use ReleaseDc to relese device context

0
 
LVL 1

Author Comment

by:Pavel040997
ID: 1463235
Can you please show how do i call those functions exactly ,couse i'm having problem using them thanx,Pavel

0
 
LVL 3

Accepted Solution

by:
AndreasSchindler earned 20 total points
ID: 1463236
Use following Code as Module; Call (for example) FormToClipboard Form1:

Option Explicit

Global Const CF_Bitmap = 2       ' Clipboard-Handle for Bitmap
Global Const SRCCopy = &HCC0020  ' Copy

Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Declare Function CloseClipboard Lib "user32" () As Long
Declare Function EmptyClipboard Lib "user32" () As Long
Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
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
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long


Public Sub FormToClipboard(frm As Form)

Dim dx&, dy&
Dim hSourcDC&, hDestDC&
Dim hBM&
Dim h&
 
 dx = frm.ScaleWidth
 dy = frm.ScaleHeight
 hSourcDC = GetDC(frm.hwnd)
 hDestDC = CreateCompatibleDC(hSourcDC)
 hBM = CreateCompatibleBitmap(hSourcDC, dx, dy)
 h = SelectObject(hDestDC, hBM)
 Call BitBlt(hDestDC, 0, 0, dx, dy, hSourcDC, 0, 0, SRCCopy)
 Call OpenClipboard(frm.hwnd)
 EmptyClipboard
 Call SetClipboardData(CF_Bitmap, hBM)
 CloseClipboard
 DeleteObject SelectObject(hSourcDC, h)
 Call DeleteDC(hDestDC)
 Call ReleaseDC(frm.hwnd, hSourcDC)
End Sub


0
 
LVL 1

Author Comment

by:Pavel040997
ID: 1463237
thanx man
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

688 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