How to define Gradient and Brushes for TFolderEx-pages ?

How to define Gradient and Brushes for TFolderEx-pages ?

Postby ukoenig » Mon Sep 20, 2010 3:54 pm

Hello,

I have a problem, to define Grad. and Brushes for TFolderEx-pages.
The Tab-area works fine, but Pages are wrong.
Testing with TFolder, it works.

I testded on Dialog-Init and Paint with the same result.

Code: Select all  Expand view

...
// c_path := CURDRIVE() + ":\" + GETCURDIR()
// 1 = Color, 2 = Grd-Brush, 3 = Brush, 4 = Image
// nFStyle := 2 // => Gradient
// nFColPos := 0.5
// lFDirect  := .T.
// nFColor1 := 32768
// nFColor2 := 16777215
// cFBrush   := "Marble.bmp"
// cFImage := "Backgrd.jpg"
...
ACTIVATE DIALOG oDlg ;
ON INIT ( FOLD_BACK( nFStyle, ; // 1= Color, 2 = Gradient, 3 = Brush, 4 = Image
          oFld1, ;
          nFColPos, ; // Gradient - position
          nFColor1, ; // 1. Color
          nFColor2, ; // 2. Color
          lFDirect, ; // Direction .T. or .F.
          c_Path + "\Images\" + cFBrush, ; // Brush
          c_Path + "
\Images\" + cFImage ) ) // Image

RETURN NIL

// ------ any Folder-Tab Background ----------------------

FUNCTION FOLD_BACK( nStyle, oFld, nCpos, nColor1, nColor2, lDirect, cBrush, cImage )
LOCAL n, oFDlg, oBrush, oTmp, hDC, aGrad

FOR n = 1 to Len( oFld:aDialogs )
   oFDlg = oFld:aDialogs[ n ]  
   IF nStyle = 1 // Color
      DEFINE BRUSH oBrush COLOR nColor1
      oFDlg:SetBrush( oBrush ) 
      RELEASE BRUSH oBrush
   ENDIF
   IF nSTYLE = 2 // Gradient
      aGrad := { { nCPos, nColor1, nColor2 }, { nCPos, nColor2, nColor1 } }
      IF Empty( oFDlg:oBrush:hBitmap )
          hDC = CreateCompatibleDC( oFDlg:GetDC() )
          hBmp = CreateCompatibleBitMap( oFDlg:hDC, oFDlg:nWidth, oFDlg:nHeight )
          hBmpOld = SelectObject( hDC, hBmp )
          GradientFill( hDC, 0, 0, oFDlg:nHeight, oFDlg:nWidth, aGrad, lDirect )
          DeleteObject( oFDlg:oBrush:hBrush )
          oFDlg:oBrush:hBitmap = hBmp
          oFDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
          SelectObject( hDC, hBmpOld )
          oFDlg:ReleaseDC()
      ENDIF  
   ENDIF
   IF nStyle = 3 // Brush
      DEFINE BRUSH oBrush FILENAME cBrush
      oFDlg:SetBrush( oBrush ) 
      RELEASE BRUSH oBrush
   ENDIF
   IF nStyle = 4 // Image
      DEFINE IMAGE oTmp FILENAME cImage
      oBrush := TBrush():new( ,,,, ResizeBmp( oTmp:hBitmap, oFDlg:nWidth, oFDlg:nHeight, .T. ) )
      SET BRUSH OF oFDlg TO oBrush
      oTmp:End()
      RELEASE BRUSH oBrush
   ENDIF
NEXT

RETURN NIL      


My tests :

A Gradient
Image

A Brush with painted Grid
Image

A resized Image
Image

The Function used with TFolder ( Brush with painted Grid )
The Background for Radio and Checkbox is OK.
There is a transparent-problem with Group-Text.
Image

Best Regards
Uwe :roll:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 40 guests