Guest_imported
New member
- Jan 1, 1970
- 0
Do you know some command to put the image of the screen in clipboard, or some part of it?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Placing the active window (retrieved with GetFocus) on the clipboard as BMP image
#DEFINE CF_BITMAP 2 && clipboard format
#DEFINE SRCCOPY 13369376 && BitBlt raster operation code
DO decl
PRIVATE hwnd, lnLeft, lnTop, lnRight, lnBottom, lnWidth, lnHeight
hwnd = GetFocus() && a window with keyboard focus
* retrieving geometrical parameters of the window
STORE 0 TO lnLeft, lnTop, lnRight, lnBottom, lnWidth, lnHeight
= getRect (@lnLeft, @lnTop, @lnRight, @lnBottom, @lnWidth, @lnHeight)
* and its device context
hdc = GetWindowDC (hwnd)
* creating compatible DC and BITMAP
hVdc = CreateCompatibleDC (hdc)
hBitmap = CreateCompatibleBitmap (hdc, lnWidth, lnHeight)
= SelectObject (hVdc, hBitmap) && selecting created BITMAP into hVdc
* copying a rectangular area from HDC to hVdc
= BitBlt (hVdc, 0,0, lnWidth,lnHeight, hdc, 0,0, SRCCOPY)
* opening clipboard and placing bitmap data on it
= OpenClipboard (hwnd)
= EmptyClipboard()
= SetClipboardData (CF_BITMAP, hBitmap)
= CloseClipboard() && that is important for other applications
* cleaning the place
= DeleteObject (hBitmap)
= DeleteDC (hVdc)
= ReleaseDC (hwnd, hdc)
RETURN && main
PROCEDURE decl && not a few of them
DECLARE INTEGER GetWindowRect IN user32 INTEGER hwnd, STRING @ lpRect
DECLARE INTEGER SelectObject IN gdi32 INTEGER hdc, INTEGER hObject
DECLARE INTEGER ReleaseDC IN user32 INTEGER hwnd, INTEGER hdc
DECLARE INTEGER CreateCompatibleDC IN gdi32 INTEGER hdc
DECLARE INTEGER DeleteObject IN gdi32 INTEGER hObject
DECLARE INTEGER DeleteDC IN gdi32 INTEGER hdc
DECLARE INTEGER CloseClipboard IN user32
DECLARE INTEGER GetFocus IN user32
DECLARE INTEGER EmptyClipboard IN user32
DECLARE INTEGER GetWindowDC IN user32 INTEGER hwnd
DECLARE INTEGER OpenClipboard IN user32 INTEGER hwnd
DECLARE INTEGER SetClipboardData IN user32 INTEGER wFormat, INTEGER hMem
DECLARE INTEGER CreateCompatibleBitmap IN gdi32;
INTEGER hdc, INTEGER nWidth, INTEGER nHeight
DECLARE INTEGER BitBlt IN gdi32;
INTEGER hDestDC, INTEGER x, INTEGER y,;
INTEGER nWidth, INTEGER nHeight, INTEGER hSrcDC,;
INTEGER xSrc, INTEGER ySrc, INTEGER dwRop
RETURN && decl
PROCEDURE getRect(lnLeft, lnTop, lnRight, lnBottom, lnWidth, lnHeight)
LOCAL lpRect
lpRect = Repli(Chr(0), 16)
= GetWindowRect (hwnd, @lpRect)
lnLeft = buf2dword(SUBSTR(lpRect, 1,4))
lnTop = buf2dword(SUBSTR(lpRect, 5,4))
lnRight = buf2dword(SUBSTR(lpRect, 9,4))
lnBottom = buf2dword(SUBSTR(lpRect, 13,4))
lnWidth = lnRight - lnLeft
lnHeight = lnBottom - lnTop
RETURN
FUNCTION buf2dword (lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
Asc(SUBSTR(lcBuffer, 4,1)) * 16777216