Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Automating capturing the current screen with
Message
 
À
05/02/2003 11:30:22
Dave Nantais
Light speed database solutions
Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00749392
Message ID:
00749434
Vues:
22
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform