Page 1 of 1

Gradient on TPanel?

Posted: Mon Aug 31, 2009 5:57 pm
by JC
Dear Antonio and friends, Good afternoon!

Exists any way to create a gradient effect into TPanel class? The visual effect 2007?

Re: Gradient on TPanel?

Posted: Mon Aug 31, 2009 6:43 pm
by ukoenig
A preliminary Solution :
Create a Gradient-Bmp and use it as a Brush.
If You want to use a vertical-gradient, the Bmp-length must be >= Panel-length,
otherwise the gradient is shown tiled.

Image

DEFINE BRUSH oBrush FILENAME "..\bitmaps\16x16\Gradient1.bmp"

oPanel := TPanel():New( 0, 0, 75, 290, oReBar )
oPanel:SetBrush( oBrush )

Best Regards
Uwe :lol:

Re: Gradient on TPanel?

Posted: Mon Aug 31, 2009 6:52 pm
by JC
Great Uwe!

But, without a image file... it's possible too?

Some like this:

Code: Select all

lLook2007 := .T.
oBar := TBar():New( oWnd, 100, 68, .T., "TOP",, lLook2007 )
oPanel := TPanel():New( 0, oBar:nLeft, 68, oBar:nRight, oBar )

Re: Gradient on TPanel?

Posted: Mon Aug 31, 2009 7:05 pm
by ukoenig
Hello JC,

the tPanel-Class includes only in ON PAINT :

FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )

I can test, if it is possible to change this with < Gradientfill > maybe it works.

Best regards
Uwe :lol:

Re: Gradient on TPanel?

Posted: Mon Aug 31, 2009 8:09 pm
by JC
Dear Uwe,

I tried but, not work

Code: Select all

IF ::l2007
   GradientFill( ::hDC, 0, 0, ::nHeight, ::nWidth, Eval( ::bClrGrad, .f. ) )
   return 0
ENDIF

Re: Gradient on TPanel?

Posted: Mon Aug 31, 2009 11:54 pm
by Silvio
tpanel has an error on paint method.
Antonio erased the line where call the function floodfill because when we use different tpanel there is an error on hbrush variable.
If you want the same effect of tpanel you must create a dialog with Nor 4 style and insert at right scrollbar if you want.
Only with this dialog tou can use graduent functiin to
colorize it.
but this is only an mine idea!