Delphi 3 Win32 图形 API 绘画与绘图函数详解
1. 创建新笔(CreatePen)
1.1 代码示例
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 squar