Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automating capturing the current screen with
Message
 
To
05/02/2003 11:30:22
Dave Nantais
Light speed database solutions
Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00749392
Message ID:
00749434
Views:
21
This message has been marked as the solution to the initial question of the thread.
The 'current screen' term -- it is either current FoxPro form, or main VFP window, or Windows Desktop. Depending on what you need, use Win32 functions
- GetFocus
- GetActiveWindow
- GetDesktopWindow
to get a window handle. Sometimes all of them can return same result.

Let's say:
hWindow = GetActiveWindow()

Now use this handle to get a device context for the window (release it in the end):
hDC = GetWindowDC(hWindow)

There is a bitmap "inside" this device context. Somehow you need to get its data and pass it to the Clipboard. Here is a way:

- create compatible device context -- hMemDC
- create compatible bitmap (hMemBMP) and select this bitmap into hMemDC
- copy bitmap data between hDC and hMemDC using BitBlt function

Win32 functions used: CreateCompatibleBitmap, CreateCompatibleDC, SelectObject, BitBlt

After these steps the compatible bitmap contains a picture of the current screen. And hMemBMP is exactly what you need to proceed.

Next set of steps:
- open Clipboard
- empty Clipboard
- set Clipboard data using the hMemBMP value
- close Clipboard

Win32 functions used: OpenClipboard, EmptyClipboard, SetClipboardData, CloseClipboard. Here it is -- your current screen is now in the clipboard as a bitmap.

* * *
In the end do not forget to release system resources: hDC, hMemDC, hMemBMP

* * *
Check complete FoxPro code at http://www.news2news.com/vfp/?example=91
Previous
Reply
Map
View

Click here to load this message in the networking platform