Code: Select all
#include "fivewin.ch"
CLASS TBrushNew FROM TBrush
METHOD New( nColor, nColor2, lVGrad ) CONSTRUCTOR
ENDCLASS
METHOD New( nWidth, nHeight, nColor, nColor2, lGradient ) CLASS TBrushNew
::hBitmap := CreaBitmap2Color(nWidth, nHeight, nColor, nColor2, lGradient )
::hBrush = If( ::hBitmap != 0, CreatePatternBrush( ::hBitmap ), )
::nCount := 1
AAdd( ::aBrushes, Self )
return Self
function CreaBitmap2Color( nWidth, nHeight, nColor, nColor2, lGradient )
local hDC := CreateDC( "DISPLAY",0,0,0 )
local hDCMem := CreateCompatibleDC( hDC )
local hBmpMem := CreateCompatibleBitmap( hDC, nWidth, nHeight )
local hOldBmp := SelectObject( hDCMem, hBmpMem )
local rc := {0,0,nHeight,nWidth}
if lGradient == nil; lGradient := .t.; endif
if nColor2 == nil; nColor2 := nColor; endif
if lGradient
Gradient( hDCMem, {rc[1],rc[2],rc[3]+2,rc[4]}, nColor, nColor2, .t. )
else
Gradient( hDCMem, {rc[1],rc[2],rc[3]+2,rc[4]}, nColor, nColor2, .F. )
endif
SelectObject( hDCMem, hOldBmp )
DeleteDC( hDCMem )
DeleteDC( hDC )
return hBmpMem