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

GetHeight

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

描述

 

获取箭头帽的高度.高度是箭头的底部到顶点的距离.

 

C++ Syntax

 

REAL GetHeight();

 

FreeBASIC 语法

 

FUNCTION GetHeight () AS SINGLE

 

参数

 

该方法没有参数.

 

返回值

 

此方法返回箭头帽的高度.

 

引用文件

 

CGpLineCaps.inc (include CGdiPlus.inc)

 

示例

 

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

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

' cap. The code then creates a Pen, assigns myArrow as the ending line cap for the Pen,

' and draws a capped line. Next, the code gets the height of the arrow cap, creates a new

' arrow cap with height equal to the height of myArrow, assigns the new arrow cap as the

' ending line cap for the Pen, and draws another capped line.

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

SUB Example_GetHeight (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, 20, 100, 20)

 

  ' // Create a second arrow cap using the height of the first one

  DIM AS CGpAdjustableArrowCap otherArrow = CGpAdjustableArrowCap(myArrow.GetHeight, 20, CTRUE)

  otherArrow.SetWidthScale(rxRatio)

 

  ' // Assign the new arrow cap as the end cap for arrowPen

  arrowPen.SetCustomEndCap(@otherArrow)

 

  ' // Draw a line using arrowPen

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

 

END SUB

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