直接上代码:

 

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Clipbrd;

type
TForm1
= class(TForm)
btn1: TButton;
dlgSave1: TSaveDialog;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
var
bmp:TBitmap;
MyRect:TRect;
Myrect2:TRect;
canvas:TCanvas;
DC:HDC;
b:TPoint;
aa:TPoint;
begin
ShowMessage(
'---------------');
bmp :
= TBitmap.Create;
bmp.Width :
= Form1.Width;
bmp.Height :
= form1.Height;
MyRect :
= Rect(Form1.Left,Form1.Top,bmp.Width+Form1.Left,bmp.height+Form1.Top);
Myrect2 :
=Rect(0,0,bmp.Width,bmp.height);
DC :
= GetDC(0);
Canvas :
= TCanvas.Create;
Canvas.Handle :
= DC;
bmp.Canvas.CopyRect(MyRect2,Canvas,MyRect);
Clipboard.Assign(bmp);
if dlgSave1.Execute then
bmp.SaveToFile(dlgSave1.FileName
+ '.bmp');
Canvas.Free;
ReleaseDC(
0,DC);
bmp.Free;


end;

end.

 

相关文章:

  • 2021-07-05
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2021-08-07
  • 2021-12-10
  • 2022-01-23
相关资源
相似解决方案