求助:取得VFP显示图片 在频幕上的 绝对位置 结束位置 及宽高和高度
在用VFP 截图 时,因为不能得准确的图片位置和长宽,截出来的图片总是不如意:
以下是网上找到的:就是这个数字弄不准确,在别的设备结果又不一样 Clipform(50, 20, 500, 300)
Clea
= Clipform(50, 20, 500, 300)
retu
*----------------------------------
Function Clipform
Lparameters lnLeft, lnTop, lnRight, lnBottom
#Define CF_BITMAP 2 && clipboard format
#Define SRCCOPY 13369376 && BitBlt raster operation code
Declare INTEGER GetLastError IN kernel32
Declare INTEGER GetActiveWindow IN user32
Declare INTEGER GetWindowDC IN user32 INTEGER hwnd
Declare INTEGER GetDC IN user32 INTEGER hwnd
Declare INTEGER CreateCompatibleDC IN gdi32 INTEGER hdc
Declare INTEGER DeleteDC IN gdi32 INTEGER hdc
Declare INTEGER CreateCompatibleBitmap IN gdi32;
INTEGER hdc,;
INTEGER nWidth,;
INTEGER nHeight
Declare INTEGER ReleaseDC IN user32 INTEGER hwnd, INTEGER hdc
Declare INTEGER SelectObject IN gdi32 INTEGER hdc, INTEGER hObject
Declare INTEGER DeleteObject IN gdi32 INTEGER hObject
Declare INTEGER BitBlt IN gdi32;
INTEGER hDestDC,;
INTEGER x, INTEGER y,;
INTEGER nWidth, INTEGER nHeight,;
INTEGER hSrcDC,;
INTEGER xSrc, INTEGER ySrc,;
INTEGER dwRop
Declare INTEGER OpenClipboard IN user32 INTEGER hwnd
Declare INTEGER CloseClipboard IN user32
Declare INTEGER EmptyClipboard IN user32
Declare INTEGER SetClipboardData IN user32 INTEGER wFormat, INTEGER hMem
* width and height of the rectangular area
lnWidth = lnRight - lnLeft + 1
lnHeight = lnBottom - lnTop + 1
* define HWND and DC for the main VFP window
HWnd = GetActiveWindow()
* try both HDC values and note the difference
hdc = GetWindowDC (hwnd) && device context of the whole window
* hdc = GetDC (hwnd) && device context of the client area
* creating compatible DC and BITMAP
hVdc = CreateCompatibleDC (hdc)
hBitmap = CreateCompatibleBitmap (hdc, lnWidth, lnHeight)
= SelectObject (hVdc, hBitmap) && insert created BITMAP into hVdc
* copying a rectangular area from HDC to hVdc
= BitBlt (hVdc, 0,0, lnWidth,lnHeight,;
hdc, lnLeft,lnTop, SRCCOPY)
* opening clipboard and place bitmap data into it
= OpenClipboard (hwnd)
= EmptyClipboard()
lnResult = SetClipboardData (CF_BITMAP, hBitmap)
If lnResult <> 0
* Done! See the fragment appeared in Clipboard viewer
Else
? "Error code: "
?? GetLastError()
Endif
* closing the clipboard -- important
= CloseClipboard()
* cleaning the place
= DeleteObject (hBitmap)
= DeleteDC (hVdc)
= ReleaseDC (hwnd, hdc)
Return && main
Endfunc