主题:高手请进,一般人解决不了的抓屏问题
以下是一段抓屏的代码,我把这些词句复制到一个服务程序时里,为什么只得到一个白屏,
好像是只本就没有抓到屏
var
Fullscreen:Tbitmap;
FullscreenCanvas:TCanvas;
dc:HDC;
begin
Fullscreen:=TBitmap.Create;
//创建一个BITMAP来存放图象
Fullscreen.Width:=screen.width;
Fullscreen.Height:=screen.Height;
DC:=GetDC(0);
//取得屏幕的DC,参数0指的是屏幕
FullscreenCanvas:=TCanvas.Create;
//创建一个CANVAS对象
FullscreenCanvas.Handle:=DC;
Fullscreen.Canvas.CopyRect(Rect(0,0,screen.Width,screen.Height),
fullscreenCanvas,Rect(0,0,Screen.Width,Screen.Height));
//把整个屏幕复制到BITMAP中
FullscreenCanvas.Free;
//释放CANVAS对象
ReleaseDC(0,DC);
//释放DC
Image1.Picture.Bitmap:=fullscreen;
//拷贝下的图象赋给IMAGE对象
Image1.Width:=fullscreen.Width;
Image1.Height:=fullscreen.Height;
fullscreen.free;
//释放bitmap
end;
好像是只本就没有抓到屏
var
Fullscreen:Tbitmap;
FullscreenCanvas:TCanvas;
dc:HDC;
begin
Fullscreen:=TBitmap.Create;
//创建一个BITMAP来存放图象
Fullscreen.Width:=screen.width;
Fullscreen.Height:=screen.Height;
DC:=GetDC(0);
//取得屏幕的DC,参数0指的是屏幕
FullscreenCanvas:=TCanvas.Create;
//创建一个CANVAS对象
FullscreenCanvas.Handle:=DC;
Fullscreen.Canvas.CopyRect(Rect(0,0,screen.Width,screen.Height),
fullscreenCanvas,Rect(0,0,Screen.Width,Screen.Height));
//把整个屏幕复制到BITMAP中
FullscreenCanvas.Free;
//释放CANVAS对象
ReleaseDC(0,DC);
//释放DC
Image1.Picture.Bitmap:=fullscreen;
//拷贝下的图象赋给IMAGE对象
Image1.Width:=fullscreen.Width;
Image1.Height:=fullscreen.Height;
fullscreen.free;
//释放bitmap
end;