导航:  GdiPlus Classes > GdiPlus Classes > CGpBrush Class > CGpHatchBrush Class > HatchBrush Object >

GetHatchStyle

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

描述

 

获取此舱口刷的舱盖样式.

 

C++ Syntax

 

HatchStyle GetHatchStyle() const;

 

FreeBASIC 语法

 

FUNCTION GetHatchStyle () AS HatchStyle

 

参数

 

这种方法没有参数.

 

返回值

 

此方法返回舱的风格,这是一个HatchStyle枚举的元素.

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example sets up two hatch styles: horiz and current (initialized to

' HatchStyleDiagonalCross). A rectangle that uses horiz as the hatch style is painted.

' Then the HatchBrush.GetHatchStyle method is used to get the current hatch style of the

' brush (which at the time is HatchStyleHorizontal). The address of the current HatchStyle

' object (initialized to HatchStyleDiagonalCross) is passed as the return point for the

' call to GetHatchStyle. When the rectangle is painted again, notice that the hatch style

' is again HatchStyleHorizontal (not HatchStyleDiagonalCross). This shows that the call to

' HatchBrush.GetHatchStyle was successful.

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

SUB Example_HatchBrushGetHatchStyle (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)

 

  ' // Set colors

  DIM blue AS ARGB = GDIP_ARGB(255, 0, 0, 255)          ' // foreground

  DIM turquoise AS ARGB = GDIP_ARGB(255, 0, 255, 255)   ' // background

 

  ' // Set hatch styles

  DIM horiz AS HatchStyle = HatchStyleHorizontal

  DIM current AS HatchStyle = HatchStyleDiagonalCross

 

  ' // Set and then draw the first hatch style.

  DIM brush AS CGpHatchBrush = CGpHatchBrush(horiz, blue, turquoise)

  graphics.FillRectangle(@brush, 20, 20, 100, 50)

 

  ' // Get the current hatch style of the brush.

  current = brush.GetHatchStyle

 

  ' // Get the current background color of the brush.

  brush.GetBackgroundColor(@current)

 

  ' // Draw the rectangle again using the current hatch style.

  DIM brush2 AS CGpHatchBrush = CGpHatchBrush(current, blue, turquoise)

  graphics.FillRectangle(@brush2, 130, 20, 100, 50)

 

END SUB

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