// -------- FOLDER - Backgrounds ---------------
FUNCTION FLD_BACK( oFld, nTColor, nColor1, nColor2, lDirect, nGrdPos, nCGrdPos, cBrush, cImage )
LOCAL nStyle, oFDlg, hDC, oBrush, oImage, nRow := 0, nCol := 0, lFound := .T.
LOCAL aGrad, nCTop, nCLeft, oImg
LOCAL aRect := GETCLIENTRECT( oFld:hWnd )
FOR nStyle := 1 to Len( oFld:aDialogs )
oFDlg := oFld:aDialogs[ nStyle ]
hDC = CreateCompatibleDC( oFDlg:GetDC() )
IF nStyle = 1 // COLOR
DEFINE BRUSH oBrush COLOR nColor1
ELSEIF nStyle = 2 // GRADIENT
aGrad := { { nGrdPos, nColor1, nColor2 }, { nGrdPos, nColor2, nColor1 } }
IF lDirect = .T.
DEFINE BRUSH oBrush GRADIENT aGrad STYLE "HORIZONTAL"
ELSE
DEFINE BRUSH oBrush GRADIENT aGrad STYLE "VERTICAL"
ENDIF
ELSEIF nStyle = 3 // GRADIENT diagonal
hDC = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, aRect[4], aRect[3] )
hBmpOld = SelectObject( hDC, hBmp )
DIAGGRADFILL( hDC, 0, 0, aRect[3], aRect[4], ;
{ { 0, nColor2, nColor2 }, { 0, nColor2, nColor2 }, ;
{ nGrdPos, nColor1, nColor2 }, ;
{ nGrdPos, nColor2, nColor1 }, ;
{ 1, nColor1, nColor1 }, { 1, nColor1, nColor1 } }, lDirect )
oBrush := TBrush():New( ,,,, hBmp )
oBrush:Cargo := aGrad
SelectObject( hDC, hBmpOld )
ReleaseDC(hDC)
ELSEIF nStyle = 4 // GRADIENT circle
oBrush := TBrush():New()
IF nCGrdPos = 1 // bottom / right
nOffX := nGrdPos * ( aRect[4] / 2 )
nOffY := nGrdPos * ( aRect[3] / 2 )
ENDIF
IF nCGrdPos = 2 // top / left
nOffX := - nGrdPos * ( aRect[4] / 2 )
nOffY := - nGrdPos * ( aRect[3] / 2 )
ENDIF
IF nCGrdPos = 3 // bottom / left
nOffX := - nGrdPos * ( aRect[4] / 2 )
nOffY := nGrdPos * ( aRect[3] / 2 )
ENDIF
IF nCGrdPos = 4 // top / right
nOffX := nGrdPos * ( aRect[4] / 2 )
nOffY := - nGrdPos * ( aRect[3] / 2 )
ENDIF
DeleteObject( oBrush:hBrush )
oBrush:hBrush = CircleGradient( 0, { 0, 0, aRect[3], aRect[4] } , nColor1, nColor2, nOffX, nOffY, 1 )
ELSEIF nStyle = 5 // BMP-brush
IF FILE( cBrush )
DEFINE BRUSH oBrush FILE cBrush
ELSE
IF !EMPTY(cBrush)
MsgAlert( "File : " + cBrush + CRLF + ;
"does not exist" + CRLF + ;
"to create BMP-brush !", "ATTENTION" )
lFound := .F.
ENDIF
ENDIF
ELSEIF nStyle = 6 // Image ADJUSTED
IF FILE( cImage )
DEFINE IMAGE oImage FILE cImage
oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .F. ) )
oImage:End()
ELSE
IF !EMPTY(cImage)
MsgAlert( "File : " + cImage + CRLF + ;
"does not exist" + CRLF + ;
"to create IMAGE-background !", "ATTENTION" )
lFound := .F.
ENDIF
ENDIF
ENDIF
IF lFound = .T.
oFDlg:SetBrush( oBrush )
RELEASE BRUSH oBrush
ENDIF
AEVAL( oFDlg:aControls, { | oCtl | oCtl:SetColor( nTColor, ) } )
NEXT
RETURN( NIL )