WinAPI: CreatePen - 建立画笔

2014/09/26 15:40
阅读数 297
//声明:
CreatePen(
  Style, Width: Integer; {样式与笔宽}
  Color: COLORREF        {颜色}
): HPEN;                 {返回笔句柄}

//Style 参数可选值:
PS_SOLID       = 0; {实线}
PS_DASH        = 1; {段线; 要求笔宽<=1}
PS_DOT         = 2; {点线; 要求笔宽<=1}
PS_DASHDOT     = 3; {线、点; 要求笔宽<=1}
PS_DASHDOTDOT  = 4; {线、点、点; 要求笔宽<=1}
PS_NULL        = 5; {不可见}
PS_INSIDEFRAME = 6; {实线; 但笔宽是向里扩展}

 
 
 
 
 

 

 

  
  
//举例: procedure TForm1.FormPaint(Sender: TObject); var PenStyle: Integer; {Pen 样式} PenHandle: HPEN; {Pen 句柄} begin PenStyle := RadioGroup1.ItemIndex; PenHandle := CreatePen(PenStyle, 1, clRed); Canvas.Pen.Handle := PenHandle; Rectangle(Canvas.Handle, 20, 20, 96,160); DeleteObject(PenHandle); end; procedure TForm1.RadioGroup1Click(Sender: TObject); begin Self.Refresh; end;
//效果图:

//测试 PS_SOLID 与 PS_INSIDEFRAME 的区别
procedure TForm1.FormPaint(Sender: TObject);
var
  PenHandle: HPEN;
begin
  PenHandle := CreatePen(PS_SOLID, 20, clRed);
  Canvas.Pen.Handle := PenHandle;
  Rectangle(Canvas.Handle, 20, 20, 96,132);

  PenHandle := CreatePen(PS_INSIDEFRAME, 20, clRed);
  Canvas.Pen.Handle := PenHandle;
  Rectangle(Canvas.Handle, 120, 20, 196,132);

  PenHandle := CreatePen(PS_SOLID, 1, clRed);
  Canvas.Pen.Handle := PenHandle;
  Rectangle(Canvas.Handle, 220, 20, 296,132);

  DeleteObject(PenHandle);
end;

 
 
 
 
 

 

 

  
  
//效果图:

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部