c:=TBitmap.Create;
c.Canvas.Handle:=GetDC(0); d:=TBitmap.Create;
d.Canvas.CopyRect(rect(0,0,self.ClientWidth,self.ClientHeight),c.Canvas,rect(left,top,left+clientwidth,top+clientheight)); ReleaseDC(0, c.handle); d.SaveToFile('c:\xx.bmp');怎么d里面什么都没有?
c.Canvas.Handle:=GetDC(0); d:=TBitmap.Create;
d.Canvas.CopyRect(rect(0,0,self.ClientWidth,self.ClientHeight),c.Canvas,rect(left,top,left+clientwidth,top+clientheight)); ReleaseDC(0, c.handle); d.SaveToFile('c:\xx.bmp');怎么d里面什么都没有?
解决方案 »
- TIdUDPServer如何穿透路由器
- 这样的图表怎么做,用TEECHART,谢谢!100分...
- 1stclass 的安装问题,请教!
- 球助:如何把TRichEdit组件里的内容导入到Word里。
- Delphi里如何才能准确地获得中文字符串的长度?
- ★放尽所有分★求如何提高SQL SERVER 2000的查询速度!
- 请教个位! 可以帮忙吗?(关于 C/S 在客户端执行查询时出错!)(在线等待)
- 请高手指点“ 关于tree的问题”
- 关于网际快车FlashGet 启动后右上方的显示状态的小窗口是如何实现的?~
- 类似FlashGet/NetAnts监视鼠标的点击?
- 问大家个很菜的问题,散分?在线等!!!!
- 帮帮忙,关序消息的问题!!!
var
DesktophWnd:hWnd;
DesktopDC:hWnd;
CursorhWnd:hWnd;
CurPos:Tpoint;
Rect:TRect;
Bitmap:TBitmap;
begin
DesktophWnd := GetDesktopWindow();
DesktopDC := GetDC(DesktophWnd);
GetWindowRect(DesktophWnd, Rect);
if IncludeCur then
begin
CursorhWnd:=GetCursor(); //捕获当前鼠标指针句柄
GetCursorPos(CurPos);
end; //获取当前鼠标指针的位置坐标
Bitmap := TBitmap.Create;//生成一个Tbitmap类型的实例对象
Bitmap.Width := Rect.Right-Rect.Left;
Bitmap.Height := Rect.Bottom-Rect.Top;
BitBlt(Bitmap.Canvas.Handle, 0, 0,
Bitmap.Width, Bitmap.Height, DesktopDC, 0, 0, SRCCOPY);//在抓取到的位图对象上绘制鼠标
if IncludeCur then
DrawIcon(Bitmap.Canvas.Handle, CurPos.X, CurPos.Y, CursorhWnd);
ReleaseDC(DesktophWnd, DesktopDC);
Bitmap.SaveToFile('C:\Desktop.bmp'); //使用类方法SaveToFile保存文件
Bitmap.Free;
ShowMessage('成功抓取屏幕并保存图像至C:\Desktop.bmp文件!');
end;
或者是CreateDC('DISPLAY', ...);年代久远,记不清了。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;type
TForm1 = class(TForm)
Image1: TImage;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure ScreenCapture(Bmp: TBitmap);
var
DeskWnd: HWnd;
DeskDC: HDC;
DeskCv: TCanvas;
R: TRect;
W, H: Integer;
begin
if Bmp = nil then Exit;
DeskWnd := GetDesktopWindow;
DeskDC := GetWindowDC(DeskWnd);
DeskCv := TCanvas.Create;
DeskCv.Handle := DeskDC;
W := Screen.Width;
H := Screen.Height;
R := Bounds(0, 0, W, H);
try
Bmp.HandleType := bmDIB;
Bmp.PixelFormat := pf24Bit;
Bmp.Width := W;
Bmp.Height := H;
Bmp.Canvas.CopyMode := cmSrcCopy;
Bmp.Canvas.CopyRect(R, DeskCv, R);
finally
DeskCv.Free;
ReleaseDC(DeskWnd, DeskDC);
end;
end; {Marco Lange}procedure TForm1.BitBtn1Click(Sender: TObject);
begin
ScreenCapture(image1.Picture.Bitmap);
end;end.