导航:  GdiPlus Classes > GdiPlus Classes > CGpBrush Class > CGpSolidBrush Class > SolidBrush Object >

SetColor

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

描述

 

设置此固体画笔的颜色.

 

C++ Syntax

 

Status SetColor(

[in, ref]  const Color &color

);

 

FreeBASIC 语法

 

FUNCTION SetColor (BYVAL colour AS ARGB) AS GpStatus

 

参数

 

colour

 

[in]颜色被设置在固体刷.

 

返回值

 

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

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

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a solid brush and uses it to fill a rectangle. The code

' uses GdipSetSolidFillColor to change the color of the solid brush and then paints a

' second rectangle the new color.

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

SUB Example_SetColor (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 a solid brush, and use it to fill a rectangle

  DIM solidBrush AS CGpSolidBrush = GDIP_ARGB(255, 0, 0, 255)

  graphics.FillRectangle(@solidBrush, 10, 10, 200, 100)

 

  ' // Change the color of the brush to red, and fill another rectangle

  solidBrush.SetColor(GDIP_ARGB(255, 255, 0, 0))

  graphics.FillRectangle(@solidBrush, 220, 10, 200, 100)

 

END SUB

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