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

GetBackgroundColor

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

描述

 

获取此舱口刷的背景颜色.

 

C++ Syntax

 

Status GetBackgroundColor(

[out]  Color *color

) const;

 

FreeBASIC 语法

 

FUNCTION GetBackgroundColor ( _

   BYVAL colour AS ARGB PTR _

) AS GpStatus

 

参数

 

colour

 

[out]变量指针接收背景颜色.背景颜色定义了绘制线条的颜色.

 

返回值

 

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

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

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example sets up three Color objects: black, turquoise, and current

' (initialized to black). A rectangle is painted by using turquoise as the background

' color and black as the foreground color. Then the HatchBrush.GetBackgroundColor method

' is used to get the current color of the brush (which at the time is turquoise). The

' address of the current Color object (initialized to black) is passed as the return point

' for the call to HatchBrush,GetBackgroundColor. When the rectangle is painted again,

' note that the background color is again turquoise (not black). This shows that the call

' to HatchBrush.GetBackgroundColor was successful.

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

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

 

  ' // Set colors

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

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

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

 

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

  DIM brush AS CGpHatchBrush = CGpHatchBrush(HatchStyleHorizontal, black, turquoise)

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

 

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

  brush.GetBackgroundColor(@current)

 

  ' // Draw the rectangle again using the current color.

  DIM brush2 AS CGpHatchBrush = CGpHatchBrush(HatchStyleDiagonalCross, black, current)

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

 

END SUB

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