How to use GET with different Gradient ?

How to use GET with different Gradient ?

Postby ukoenig » Wed Aug 25, 2010 5: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: Select all  Expand view

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
Image

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

Best Regards
Uwe :roll:
Last edited by ukoenig on Wed Aug 25, 2010 5:35 pm, edited 1 time in total.
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

Re: How to use GET with different Gradient ?

Postby Daniel Garcia-Gil » Wed Aug 25, 2010 5: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: Select all  Expand view
        oBrush = TBrush():New( , , , , hBmp)  
        oControl:SetBrush( oBrush )
        DeleteObject( hBmp )
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: How to use GET with different Gradient ?

Postby ukoenig » Wed Aug 25, 2010 5: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: Select all  Expand view

#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 :lol:
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: No registered users and 89 guests