多谢
解决方案 »
- 关于PNG 图形的旋转问题,求救~~
- DP初学者问1:
- 问一个关于4字节浮点数的问题
- 关于按钮的问题!
- 如何将本地的EXCEL文件导入到远程SQL SERVER2000数据库中!
- 有变量n,怎么样动态的建n个label?
- 关于PACS的图象处理代码,请高手帮助阅读一下谢谢
- Delphi 会被 Visual Studio.net 打败吗?(请所有 Delphi 爱好者进来)
- 怎样实现软件里“给作者写信”和“到作者主业”的功能,如flashget
- 怎样得到一个文件的路径?
- delphi中:要在form1.button1.click事件中调用form1.Formclose()事件,我要怎样做?
- clientsocket如何连接到游戏服务器??!
procedure ScreenCap(LeftPos,TopPos,
RightPos,BottomPos:integer);
var
RectWidth,RectHeight:integer;
SourceDC,DestDC,Bhandle:integer;
Bitmap:TBitmap;
begin
RectWidth:=RightPos-LeftPos;
RectHeight:=BottomPos-TopPos;
SourceDC:=CreateDC('DISPLAY','','',nil);
DestDC:=CreateCompatibleDC(SourceDC);
Bhandle:=CreateCompatibleBitmap(SourceDC,
RectWidth,RectHeight);
SelectObject(DestDC,Bhandle);
BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC,
LeftPos,TopPos,SRCCOPY);
Bitmap:=TBitmap.Create;
Bitmap.Handle:=BHandle;
BitMap.SaveToStream(BmpStream);
BmpStream.Position:=0;
LeftSize:=BmpStream.Size;
Bitmap.Free;
DeleteDC(DestDC);
ReleaseDC(Bhandle,SourceDC);
end;
代码如下:
procedure TClient.ScreenCap(LeftPos,TopPos,
RightPos,BottomPos:integer);
var
RectWidth,RectHeight:integer;
SourceDC,DestDC,Bhandle:integer;
Bitmap:TBitmap;
begin
RectWidth:=RightPos-LeftPos;
RectHeight:=BottomPos-TopPos;
SourceDC:=CreateDC('DISPLAY','','',nil);
{创建源设备环境,DISPLAY为显示器}DestDC:=CreateCompatibleDC(SourceDC);
{创建和SourceDC兼容的目标设备环境}
Bhandle:=CreateCompatibleBitmap(SourceDC,
RectWidth,RectHeight);
{创建一个和SourceDC兼容的内存设备环境,并返回其设备句柄}
SelectObject(DestDC,Bhandle); BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC,
LeftPos,TopPos,SRCCOPY); Bitmap:=TBitmap.Create;
Bitmap.Handle:=BHandle;
BitMap.SaveToStream(BmpStream);
BmpStream.Position:=0;
LeftSize:=BmpStream.Size;
Bitmap.Free;
DeleteDC(DestDC);
ReleaseDC(Bhandle,SourceDC);
end;
var
DC : HDC;
ABitmap : TBitmap;
CI: TCursorInfo;
begin
DC := GetDC(GetDesktopWindow);
ABitmap := TBitmap.Create;
try
ABitmap.Width := GetDeviceCaps(DC,HORZRES);
ABitmap.Height := GetDeviceCaps(DC,VERTRES);// ScreenBmp.Width := screen.Width;
// ScreenBmp.Height := screen.Height;
// ABitmap.PixelFormat := pf8Bit; BitBlt(ABitmap.Canvas.Handle,
0,
0,
ABitmap.Width,
ABitmap.Height,
DC,
0,
0,
SRCCOPY);
ZeroMemory(@CI,SizeOf(CI));
CI.cbSize := SizeOf(CI);
if GetCursorInfo(CI) then
DrawIconEx(ABitmap.Canvas.Handle,
CI.ptScreenPos.X,
CI.ptScreenPos.Y,
CI.hCursor,
16,
16,
0,
0,
DI_DEFAULTSIZE OR DI_NORMAL); finally
ReleaseDC(GetDesktopWindow,DC);
end;
Result := ABitmap;
end;
转贴
将当前显示画面抓取到一个paintbox中:
begin
desktop:=Tcanvas.create;
with desktop do
handle:=getwindowsdc(getdesktopwindow);
with paintbox1.canvas do
begin
copyrect(rect(0,0,paint1box.width,panit1box.height),desktop,rect(0,0,screen.width,screen.height));
end;
end;
这一句:handle:=getwindowsdc(getdesktopwindow);怎么理解啊?