Solved

PrintScreen

Posted on 1998-06-13
8
436 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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

14 Experts available now in Live!

Get 1:1 Help Now