导航:  GdiPlus Classes > GdiPlus Classes > CGpCustomLineCap Class > CustomLineCap Object >

GetStrokeCaps

上一页返回章节概述下一页

描述

 

获取启动线帽和结束线帽的端帽样式.行帽是在路径中结束单个行的对象.

 

C++ Syntax

 

Status GetStrokeCaps(

[out]  LineCap *startCap,

[out]  LineCap *endCap

);

 

FreeBASIC 语法

 

FUNCTION GetStrokeCaps ( _

   BYVAL startCap AS LineCap PTR, _

   BYVAL endCap AS LineCap PTR _

) AS GpStatus

 

参数

 

startCap

 

[out]变量指针接收指示用在底线开始的线帽的LineCap枚举元素.

 

endCap

 

[out]变量指针接收指示用在终点要画出的线帽的LineCap枚举元素.

 

引用文件

 

CGpLineCaps.inc (include CGdiPlus.inc)

 

示例

 

' ========================================================================================

' The following example creates a CustomLineCap object and sets its start and end line caps.

' It then gets the line caps and assigns them as the start and end caps of a Pen object

' that it then uses to draw a line.

' ========================================================================================

SUB Example_GetStrokeCaps (BYVAL hdc AS HDC)

 

  ' // Create a graphics object from the window device context

  DIM graphics AS CGpGraphics = hdc

  ' // Get the DPI scaling ratio

  DIM rxRatio AS SINGLE = graphics.GetDpiX / 96

  DIM ryRatio AS SINGLE = graphics.GetDpiY / 96

  ' // Set the scale transform

  graphics.ScaleTransform(rxRatio, ryRatio)

 

  ' // Create a Path object, and add two lines to it

  DIM pts(0 TO 2) AS GpPoint = {GDIP_POINT(-15, -15), GDIP_POINT(0, 0), GDIP_POINT(15, -15)}

'#ifdef __FB_64BIT__

'   DIM pts(0 TO 2) AS GpPoint = {(-15, -15), (0, 0), (15, -15)}

'#else

'   ' // With the 32-bit compiler, the above syntax can't be used because a mess in the

'   ' // FB headers for GdiPlus: GpPoint is defined as Point in 64 bit and as Point_ in 32 bit.

'   DIM pts(0 TO 2) AS GpPoint

'   pts(0).x = -15 : pts(0).y = -15 : pts(2).x = 15: pts(2).y = -15

'#endif

 

  DIM capPath AS CGpGraphicsPath = FillModeAlternate

  capPath.AddLines(@pts(0), 3)

 

  ' // Create a CustomLineCap object, and set its base cap to LineCapRound

  DIM custCap AS CGpCustomLineCap = CGpCustomLineCap(NULL, @capPath)

 

' // Set the start and end caps for custCap.

  custCap.SetStrokeCaps(LineCapTriangle, LineCapRound)

 

' // Get the start and end caps from custCap.

  DIM AS LineCap startStrokeCap, endStrokeCap

  custCap.GetStrokeCaps(@startStrokeCap, @endStrokeCap)

 

' // Create a Pen object, assign startStrokeCap and endStrokeCap as the

' // start and end caps, and draw a line.

  DIM strokeCapPen AS CGpPen = CGpPen(GDIP_ARGB(255, 0, 0, 0), 15.2)

  strokeCapPen.SetLineCap(startStrokeCap, endStrokeCap, DashCapFlat)

  graphics.DrawLine(@strokeCapPen, 100, 100, 300, 100)

 

END SUB

' ========================================================================================