Hi,
I get the device context of someone else's application or browser window:
hDC:=GetWindowDc(FindWindow(...))
Then I need to put this device context on my window. How can I do this ?
SENDKEY( VK_SNAPSHOT )
LOCAL hBitmap_aux
IF .NOT. ( BT_BitmapClipboardIsEmpty() )
hBitmap_aux := BT_BitmapClipboardGet( "Win1" )
IF hBitmap_aux <> 0
BT_BitmapClipboardClean( "Win1" )
BT_BitmapRelease( hBitmap )
hBitmap := hBitmap_aux
Image_Width := BT_BitmapWidth( hBitmap )
Image_Height := BT_BitmapHeight( hBitmap )
BT_ClientAreaInvalidateAll( "Win1" )
ENDIF
ENDIF
RETURN
// create DC and draw Bitmap with Desktop Size
hDC1 := BT_CreateDC (hBitmap1, BT_HDC_BITMAP, @BTstruct1)
Width1 := BT_DesktopWidth()
Height1 := BT_DesktopHeight()
BT_DrawBitmap (hDC1, 0,0, Width1, Height1, BT_COPY, hBitmap1)
// create empty Bitmap
hBitmap2 := BT_BitmapCreateNew (nPicWidth-10, nPicHeight, {255,0,0} )
hDC2 := BT_CreateDC (hBitmap2, BT_HDC_BITMAP, @BTstruct2)
// draw from DC1 to DC2 only within Pos / Size
BT_DrawDCtoDC (hDC2, 0, 0, nPicWidth-10, nPicHeight, BT_COPY ,;
hDC1,Row+nTitlebar+8, Col+10, Width-10, Height)
// now save Result
BT_BitmapSaveFile (hBitmap2, cFileName2, nTypePicture)
// clean up
BT_DeleteDC (BTstruct1)
BT_DeleteDC (BTstruct2)
BT_BitmapRelease (hBitmap1)
BT_BitmapRelease (hBitmap2)
[code][/code]
#include "FiveWin.ch"
function Main()
local oDlg
DEFINE DIALOG oDlg
ACTIVATE DIALOG oDlg CENTER ;
ON PAINT FWRestScreen( hDC,;
FWSaveScreen( GetDesktopWindow(), 1, 1, 1000, 1000 ), 1, 1, 1000, 1000 )
return nil
#include "fivewin.ch"
//----------------------------------------------------------------------------//
function Main()
local cWin := "FiveDBU" // or any other name
local hWnd
if !EmptY( hWnd := CaptureWnd( cWin ) )
XImage( hWnd, cWin + " : Capture" )
endif
return nil
//----------------------------------------------------------------------------//
function CaptureWnd( cWin )
local hWnd, hBmp, aRect
hWnd := FindWindow(, cWin )
if Empty( hWnd )
? "Window not found"
else
if IsIconic( hWnd )
ShowWindow( hWnd, 9 )
endif
SetForeGroundWindow( hWnd )
SysRefresh()
SysWait( 1 )
aRect := GetWndRect( hWnd )
hBmp := FWSaveScreen( GetDC( 0 ), aRect[ 1 ]+3, aRect[ 2 ]+8, aRect[ 3 ]-8, aRect[ 4 ]-8 )
endif
return hBmp
//----------------------------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 83 guests