我目前正在pascal
使用中制作桌面截图lazarus
,我的截图工作但它只显示桌面的左上角。我将其设置为在TImage
. 我尝试使用MyBitmap.width := Round(370)
和MyBitmap.Height := Round(240);
但那些没有用。
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, LCLIntf, LCLType;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
MyBitmap : Tbitmap;
ScreenDC: HDC;
begin
try
MyBitmap := TBitmap.Create;
ScreenDC := GetDC(0);
MyBitmap.LoadFromDevice(ScreenDC);
MyBitmap.Width := Round(370);
Mybitmap.Height := Round(240);
ReleaseDC(0, ScreenDC);
Image1.Picture.Bitmap.Assign(MyBitmap);
finally
MyBitmap.free;
end;
end;
end.