截的图是黑的?下面是代码:
procedure PrintBakWnd(H:THandle); //H是指定要抓的窗口A的句柄
var
DC:HDC;
H1:HBITMAP;
DC1:HDC;
ScreenMap:TBitmap;
begin
DC:=GetWindowDC(H);
H1:=CreateCompatibleBitmap(DC,1020,760);
DC1:=CreateCompatibleDC(DC);
SelectObject(DC1,H1);
PrintWindow(H,DC1,0);
ScreenMap:=TBitmap.Create;
ScreenMap.Handle:=H1;
ScreenMap.SaveToFile('c:/'+FormatDateTime('YYYYMMDD-HHMMSS',Now)+'.bmp');
ScreenMap.Free;
DeleteDC(DC);
DeleteDC(DC1);
end;