⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createbrushindirectunit.pas

📁 DelphiWin32核心API参考光盘内容.是学习书籍中的源码,便于学习.
💻 PAS
字号:
unit CreateBrushIndirectUnit;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  Region: HRGN;            // a handle to a region
  LogBrush: TLogBrush;     // holds logical brush information
  NewBrush: HBrush;        // a handle to the new brush
begin
  {define the attributes of the new brush}
  with LogBrush do
  begin
    lbStyle := BS_HATCHED;
    lbColor := clBlue;
    lbHatch := HS_CROSS;
  end;

  {create the brush}
  NewBrush := CreateBrushIndirect(LogBrush);

  {create a region to fill}
  Region := CreateEllipticRgnIndirect(PaintBox1.BoundsRect);

  {fill the region with the new brush}
  FillRgn(PaintBox1.Canvas.Handle, Region, NewBrush);

  {delete the region and brush}
  DeleteObject(NewBrush);
  DeleteObject(Region);
end;

end.

⌨️ 快捷键说明

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