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

📄 ucreatepen.pas

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

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
var
  Style: Integer;     // holds the pen styles
  PenHandle: HPen;    // the handle of the pen
begin
  {erase any previous image}
  Canvas.Brush.Color := clBtnFace;
  Canvas.FillRect(Rect(10, 10, 111, 111));

  {determine the pen style}
  case RadioGroup1.ItemIndex of
    0: Style := PS_SOLID;
    1: Style := PS_DASH;
    2: Style := PS_DOT;
    3: Style := PS_DASHDOT;
    4: Style := PS_DASHDOTDOT;
    5: Style := PS_NULL;
    6: Style := PS_INSIDEFRAME;
  end;

  {create the pen}
  PenHandle := CreatePen(Style, 1, 0);

  {instruct the canvas to use the new pen}
  Canvas.Pen.Handle := PenHandle;

  {draw a square with the pen}
  Canvas.MoveTo(10, 10);
  Canvas.LineTo(110, 10);
  Canvas.LineTo(110, 110);
  Canvas.LineTo(10, 110);
  Canvas.LineTo(10, 10);

  {delete the pen}
  DeleteObject(PenHandle);
end;

end.

⌨️ 快捷键说明

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