TBrushEx

Fonte: source/classes/brushex.prg

Standalone class (no inheritance)

TBrushEx creates extended GDI brush objects with gradient patterns. Unlike a standard solid-color brush, TBrushEx generates a bitmap filled with a smooth gradient between two (or four) colors, then creates a pattern brush from that bitmap. This allows windows and controls to be painted with gradient backgrounds without manual gradient drawing code.

Key DATA Members

DATATypeDescription
hBrushNumeric (Handle)Windows GDI brush handle created from the gradient bitmap
hBitmapNumeric (Handle)Handle to the gradient bitmap that backs the brush

Methods

MethodDescription
New( nWidth, nHeight, nColor, nColor2, lVGrad )Create a two-color gradient brush. lVGrad is .T. for vertical gradient, .F. (default) for horizontal.
NewEx( nWidth, nHeight, nC1, nC2, nC3, nC4, lVGrad )Create a four-color gradient brush with two additional corner colors for more complex patterns.
End()Delete both the brush and the bitmap, releasing all GDI resources.

Example

#include "FiveWin.ch"

function Main()

   local oWnd, oBrush

   DEFINE WINDOW oWnd TITLE "TBrushEx Demo" SIZE 400, 300

   // Create a horizontal red-to-blue gradient brush
   oBrush := TBrushEx():New( 400, 300, CLR_RED, CLR_BLUE, .F. )

   oWnd:SetBrush( oBrush )
   oWnd:lTransparent := .F.

   ACTIVATE WINDOW oWnd CENTERED

   oBrush:End()

return nil

Notes

Veja Também