Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Somebody has a routine to put screen on clipboard?

Status
Not open for further replies.

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?
 
I think you use the Alt-PrtSc button combination to put the currently active window on the clipboard.

There are some useful products for doing screen dumps though - ideal for making manuals etc:


has a good one - the install is simple.


HTH Regards

Griff
Keep [Smile]ing
 
Another product I have used for years is SmartBoard. It not only stores images from print screen but also handles text ( in almost any application) & meta-files.
It's perfect for building training manuals and moving code around when writting scripts. Unlike the clipboard it does not overwrite a previous 'copy'. This link is their site
 
MonkeyMIB

This API call seems to do want you need:
Code:
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


 
are you trying to do this programaticly?
if not then:
if you are just looking for a means to capture window screens for a help file or documentation, then down load from microsoft the HTML help workshop. this includes an image editor and a screen capture that will capture the hole screen or parts. Attitude is Everything
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top