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