拍摄Delphi 7中特定区域的屏幕截图 [英] Take a screenshot of a particular area in Delphi 7
本文介绍了拍摄Delphi 7中特定区域的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个delphi形式的面板,其中包含图片,标签和其他内容。我需要在面板区域中截屏。
如何执行此操作?
I have a panel in the form delphi that contains pictures, labels and others. I need to take screenshots in the panel area. How can I perform this ?
推荐答案
假设您有一个名为Panel1的面板要截图,一个名为的按钮Button1进行屏幕截图,Image1显示屏幕截图,下面是可以使用的简单代码:
Assuming that you have a panel named Panel1 to be screenshot, a button named Button1 to do the screen shoot, and Image1 to display the screenshot, here is simple code you can use:
procedure TForm1.Button3Click(Sender: TObject);
var
bitmap: TBitmap;
dc: HDC;
begin
bitmap := TBitmap.Create();
try
dc := GetDC(Panel1.Handle);
try
bitmap.Width := Panel1.Width;
bitmap.Height := Panel1.Height;
BitBlt(
bitmap.Canvas.Handle, 0, 0, Panel1.Width, Panel1.Height,
dc, 0, 0,
SRCCOPY
);
Image1.Picture.Bitmap.Assign(bitmap);
// bitmap.SaveToFile('c:\filename.bmp');
finally
ReleaseDC(panel1.Handle, dc);
end;
finally
bitmap.Free;
end;
end;
希望有帮助。
这篇关于拍摄Delphi 7中特定区域的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文