Solved

PrintScreen

Posted on 1998-06-13
8
453 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

730 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