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
Solved

PrintScreen

Posted on 1998-06-13
8
450 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 126
VBA filters 2 64
Spell Check in VB6 13 126
clicking a shape in a frame array vb6 3 46
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

789 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