/***************************** * Source : CaptureWindow.prg * System : * Author : Phil Ide * Created: 17/10/2003 * * Purpose: * ---------------------------- * History: * ---------------------------- * 17/10/2003 14:45 PPI - Created Last change: PI 17/10/2003 16:17:27 *****************************/ #include "Xbp.ch" #include "Common.ch" #include "printWin.ch" Function CaptureWindow(oDlg) local oClp := XbpClipBoard():new():create() local aFmt local xRet local hWnd if ValType(oDlg) == 'O' hWnd := oDlg:getHWnd() elseif ValType(oDlg) == 'N' hWnd := oDlg endif PrintWindow(hWnd) if oClp:open() aFmt := oClp:queryFormats() if Len(aFmt) > 0 .and. AScan( aFmt, XBPCLPBRD_BITMAP ) > 0 xRet := oClp:getBuffer(XBPCLPBRD_BITMAP) endif oClp:close() endif return xRet Function CaptureWin2File( oDlg, cFile, nImgType ) local o local hWnd local lOk := FALSE if ValType(oDlg) == 'O' hWnd := oDlg:getHWnd() elseif ValType(oDlg) == 'N' hWnd := oDlg endif default cFile to 'ScreenDump',; nImgType to XBPBMP_FORMAT_PNG if At('.',cFile) == 0 do case case nImgType == XBPBMP_FORMAT_WIN2X .or. nImgType == XBPBMP_FORMAT_WIN3X ; .or. nImgType == XBPBMP_FORMAT_OS21X .or. nImgType == XBPBMP_FORMAT_OS22X cFile += '.bmp' case nImgType == XBPBMP_FORMAT_GIF cFile += '.gif' case nImgType == XBPBMP_FORMAT_JPG cFile += '.jpg' otherwise cFile += '.png' endcase endif o := CaptureWindow(hWnd) if ValType(o) == 'O' if FExists( cFile ) FErase( cFile ) endif lOk := o:saveFile(cFile,nImgType) endif return lOk