cretepatternbrushunit.pas

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

PAS
47
字号
unit CretePatternBrushUnit;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}
{$R BrushPatterns.Res}

procedure TForm1.Button1Click(Sender: TObject);
var
  NewBrush: HBrush;       // brush handle
  BitmapHandle: THandle;  // handle to a bitmap
begin
  {get a bitmap that is stored in the exe}
  BitmapHandle := LoadBitmap(Hinstance, 'BrushPattern');

  {Create the pattern brush with the bitmap as the pattern}
  NewBrush := CreatePatternBrush(BitmapHandle);

  {fill the region with the pattern using the brush}
  FillRect(Canvas.Handle, ClientRect, NewBrush);

  {clean up the memory}
  DeleteObject(NewBrush);
  DeleteObject(BitmapHandle);
end;

end.

⌨️ 快捷键说明

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