Solved

PrintScreen

Posted on 1998-06-13
8
440 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 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…

919 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now