setrectemtpyu.pas

来自「Delphi Win32核心API参考光盘源码 本书包含了常用的Windows」· PAS 代码 · 共 58 行

PAS
58
字号
unit SetRectEmtpyU;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormActivate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  TheRect: TRect;    // holds the rectangle

implementation

{$R *.DFM}

procedure TForm1.FormActivate(Sender: TObject);
begin
  {create a new rectangle}
  SetRect(TheRect, 8, 40, 169, 160);
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  {display the rectangle}
  Form1.Canvas.Brush.Color := clRed;
  Form1.Canvas.FillRect(TheRect);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  {empty the rectangle}
  SetRectEmpty(TheRect);

  {indicate if the rectangle is empty}
  if IsRectEmpty(TheRect) then
    Button1.Caption := 'Rectangle is empty'
  else
    Button1.Caption := 'Rectangle is not empty';

  {repaint the form to show the changes}
  Form1.Repaint;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?