procedure PrintWindow(Wnd: HWND; ATo: TBitmap);
var
hDCMem : HDC;
DC : HDC;
rect : TRect;
bmp : HBITMAP;
hOld : HGDIOBJ;
begin
hDCMem:=CreateCompatibleDC(0);
GetWindowRect(Wnd, rect);
bmp:=0;
DC:= GetDC(Wnd);
bmp:= CreateCompatibleBitmap(
DC, rect.Right-rect.Left, rect.Bottom-rect.Top);
ReleaseDC(Wnd,
DC);
hOld:=SelectObject(hDCMem, bmp);
SendMessage(wnd, wm_Print, hDCMem, PRF_CHILDREN
or PRF_CLIENT
or PRF_ERASEBKGND
or PRF_NONCLIENT
or PRF_OWNED);
selectObject(hDCMem, hold);
DeleteObject(hDCMem);
ATo.FreeImage;
ATo.Handle:=bmp;
end;
procedure ScreenShot_aktives_Fenster(Bild: TBitMap);
var
h: THandle;
begin
h := GetForeGroundWindow;
If h <> 0
then
PrintWindow(h, Bild);
end;