FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to use GET with different Gradient ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

How to use GET with different Gradient ?

Posted: Wed Aug 25, 2010 05:16 PM
Hello,

I have a small Problem, using Gradient on Get-Fields.
For a new Tool, to support Daniel's new TFolderEx-class,
I can define any Tabs with Background, Styles and different Sizes.
For every GET with different Gradient, I use Daniel's Function from the Forum.
It works, but on Refresh all Gets are changed to the Gradient from the last defined GET.
Maybe something to change ?

Code (fw): Select all Collapse
FUNCTION GRADGET( oDGet, nMove, nColor1, nColor2 )
LOCAL hBmp, oBrush
LOCAL aColors := { { nMove, nColor1, nColor2 },;
             { nMove, nColor2, nColor1 } }

oDGet:lTransparent = .T.
hBmp = GradientBmp( oDGet, oDGet:nWidth, oDGet:nHeight, aColors )
oBrush = TBrush():New( )  //<== 
oBrush:hBrush = CreatePatternBrush( hBmp )  //<== 
oDGet:SetBrush( oBrush )
DeleteObject( hBmp )

RETURN NIL


Different Gradient on Gets selected


REFRESH changes all defined Get-Gradients to the last one.


Best Regards
Uwe :-)
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.
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: How to use GET with different Gradient ?

Posted: Wed Aug 25, 2010 05:28 PM
Uwe...

sorry for delay

from 9.06 vresion
a. Now any image file ( jpg, png, etc. ) can be used to create a Brush.
b. Brush can also be created from a bitmap handle by specifying the handle as the fifth parameter of TBrush():New() method. Command support for this is not provided.

you can use

Code (fw): Select all Collapse
        oBrush = TBrush():New( , , , , hBmp)  
        oControl:SetBrush( oBrush )
        DeleteObject( hBmp )
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: How to use GET with different Gradient ?

Posted: Wed Aug 25, 2010 05:33 PM
Daniel,

Thank You very much.
I will have a look, how to solve it.

I tested with a modified \sample\testget4.prg

Code (fw): Select all Collapse
#Include "FiveWin.Ch"

Function Main()
Local oDlg
Local oGet1,oGet2,oGet3,oGet4
local cVar1 := space(11)
local nVar2 := 0
local nVar3 := 0
local dVar4 := date()

DEFINE DIALOG oDlg from 0,0 to 400,400 pixel

@ 15,15 get oGet1 var cVar1 picture "@!" ;
size 50,12 of oDlg pixel 
   
@ 40,15 get oGet2 var nVar2 picture "99999" ;
size 50,12 of oDlg pixel 

@ 65,15 get oGet3 var nVar3 picture "99999.99" ;
size 50,12 of oDlg pixel right

@ 90,15 get oGet4 var dVar4  ;
size 50,12 of oDlg pixel 

ACTIVATE DIALOG oDlg ;
ON INIT GRADGET( oDlg )

return nil
 
// ------------------------

FUNCTION GRADGET( _oDlg )
LOCAl oControl
LOCAL aColors1 := { { 0.5, 32768, 16777215 },; // Green / White
                                   { 0.5, 16777215, 32768 } }
LOCAL aColors2 := { { 0.5, 128, 16777215 },;  // Red / White
                                   { 0.5, 16777215, 128 } }
LOCAL hBmp, n
LOCAL oBrush

FOR n = 1 to Len(_oDlg:aControls)
    oControl:= _oDlg:aControls[ n ]
    IF oControl:ClassName() == "TGET"
        oControl:lTransparent = .T.
        IF n < 3
            hBmp = GradientBmp( oControl, oControl:nWidth, oControl:nHeight, aColors1 )
        ELSE
                // new Gradient for Get 3 and 4
            // -------------------------------------
            hBmp = GradientBmp( oControl, oControl:nWidth, oControl:nHeight, aColors2 )
        ENDIF
        oBrush = TBrush():New( )  //<== 
        oBrush:hBrush = CreatePatternBrush( hBmp )  //<== 
        oControl:SetBrush( oBrush )
        DeleteObject( hBmp )
     ENDIf
NEXT

RETURN NIL


Best Regards
Uwe :-)
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.

Continue the discussion