WinAPI: CreatePenIndirect - 根据笔的参数结构建立画笔


//声明:

CreatePenIndirect(

  const LogPen: TLogPen {笔结构}

): HPEN;                {返回笔句柄}



//TLogPen 是 tagLOGPEN 结构的重定义: 

tagLOGPEN = packed record

  lopnStyle: UINT;     {笔样式}

  lopnWidth: TPoint;   {笔宽; 只需要 TPoint.X}

  lopnColor: COLORREF; {颜色}

end;



//lopnStyle 可选值:

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 p: TLogPen; PH1,PH2: HPEN; begin p.lopnStyle := PS_DOT; p.lopnWidth.X := 0; {给笔宽赋值0, 会使用1像素笔宽} p.lopnColor := clRed; PH1 := CreatePenIndirect(p); PH2 := SelectObject(Canvas.Handle, PH1); Ellipse(Canvas.Handle, 20, 20, 96,132); DeleteObject(PH1); DeleteObject(PH2); end;
//效果图:
WinAPI: CreatePenIndirect - 根据笔的参数结构建立画笔

你可能感兴趣的:(create)