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

SetWidth

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

描述

 

设置箭头盖的宽度.宽度是箭头底部端点之间的距离.

 

C++ Syntax

 

Status SetWidth(

[in]  REAL width

);

 

FreeBASIC 语法

 

FUNCTION SetWidth ( _

   BYVAL nWidth AS SINGLE _

) AS GpStatus

 

参数

 

nWidth

 

[in]简单精度数,指定的宽度,单位为箭头帽.

 

返回值

 

如果该方法成功,则返回Ok,这是对Status枚举元素.

如果这个方法失败,它返回一个枚举的其他元素的Status.

 

引用文件

 

CGpLineCaps.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates an AdjustableArrowCap, myArrow, and sets the width of

' the cap to 10 pixels. The code then creates a Pen, assigns myArrow as the ending

' line cap for this Pen, and draws a capped line. Next, the code sets the width to 15

' pixels, reassigns the arrow cap to the pen, and draws a new capped line.

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

SUB Example_SetWidth (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

  ' // Set the scale transform

  graphics.ScaleTransform(rxRatio, rxRatio)

 

  ' // Create an AdjustableArrowCap with a height of 10 pixels

  DIM myArrow AS CGpAdjustableArrowCap = CGpAdjustableArrowCap(10, 10, CTRUE)

  ' // Adjust to DPI by setting the scale width

  myArrow.SetWidthScale(rxRatio)

 

  ' // Create a Pen, and assign myArrow as the end cap

  DIM arrowPen AS CGpPen = GDIP_ARGB(255, 0, 0, 0)

  arrowPen.SetCustomEndCap(@myArrow)

 

  ' // Draw a line using arrowPen

  graphics.DrawLine(@arrowPen, 0, 0, 100, 100)

 

  ' // Set the cap to the new width, and reassign the arrow cap to the pen object.

  myArrow.SetWidth(15.7)

  arrowPen.SetCustomEndCap(@myArrow)

 

  ' // Draw a line with new cap

  graphics.DrawLine(@arrowPen, 0, 40, 100, 140)

 

END SUB

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