Tgradient problem!

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

Tgradient problem!

Postby sad » May 24th, 2007, 3:03 pm

Hi there,
I'm new to this forum and i have quite a big problem with the TGradient class produced by DelphiArea.
It seems to be a powerful tool (far more optimised than my try :) ) but when i apply a Gradient to a panel containing labels, they disappear.
I tried some stuff like Invalidate, Repaint on those labels but i foud no way to make them visible.
This is not the case with comboboxes so i think it's because of the way Delphi deals with labels.
Is there something i'm missing about this class?
Do you have any answers or simply clues?
Maybe you have an example of panels displaying labels and using TGradient?
Please forget about my English and thank you in advance for your help.
Sad
sad
Active Member
Active Member
 
Posts: 5
Joined: May 24th, 2007, 2:53 pm

Postby Kambiz » May 24th, 2007, 3:33 pm

Please post your sample code here. I'll try to fix the problem.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Here is a little part of my program

Postby sad » May 24th, 2007, 3:46 pm

Here is a little part of my program.
It contains two procedures. The first one helps to apply a gradient on a TWinControl and the second one uses the first to apply the gradient to several TWinControls. On Panels 3,9,8, there are some labels that were

Code: Select all
procedure FGradient(cCouleurDebut,cCouleurFin: TColor; control:tWinControl);
var
Grad:TGradient;
begin
 Grad:=TGradient.Create(control);
 Grad.Parent:=control;
  with Grad do
  begin
    BeginUpdate;
    Style := TGradientStyle(gsLinearV);
    Width:=control.Width;
    height:=control.Height;
    ColorBegin := cCouleurDebut;
    ColorEnd:=cCouleurFin;
    EndUpdate;
  end;
end;


procedure TmffForm.ApplyGradient();
 var
colCurrent:Tcolor;
begin
  inherited;
   FGradient(RGB(255,230,191),clWhite,Self);
   FGradient(RGB(233,153,182),clWhite,Panel8);
   FGradient(RGB(233,153,182),clWhite,Panel9);
   FGradient(RGB(175,229,231),clWhite,Panel3);
Label1.Invalidate();//does not do the job
Label2.Repaint();  //neither does this
...


Thank you for your help and your fast answer.
Sad
sad
Active Member
Active Member
 
Posts: 5
Joined: May 24th, 2007, 2:53 pm

Postby Kambiz » May 24th, 2007, 5:13 pm

Here is the correction:

Code: Select all
procedure FGradient(cCouleurDebut,cCouleurFin: TColor; control:tWinControl);
var
  Grad:TGradient;
begin
  Grad:=TGradient.Create(control);
  Grad.Parent:=control;

  Grad.SendToBack; // the gradient control should place behind other controls

  with Grad do
  begin
    BeginUpdate;
    Style := gsLinearV;
    Width:=control.Width;
    height:=control.Height;
    ColorBegin := cCouleurDebut;
    ColorEnd:=cCouleurFin;
    EndUpdate;
  end;
end;


By the way, there is no need to the following calls in the other function:

Code: Select all
Label1.Invalidate();//does not do the job
Label2.Repaint();  //neither does this
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby sad » May 24th, 2007, 5:44 pm

Ok, I'll try that and i'll post tomorrow if it worked.
Thank you so much :)
Sad
sad
Active Member
Active Member
 
Posts: 5
Joined: May 24th, 2007, 2:53 pm

Postby sad » May 25th, 2007, 6:53 am

It worked nicely.
Thank you so much!
sad
Active Member
Active Member
 
Posts: 5
Joined: May 24th, 2007, 2:53 pm

Postby Kambiz » May 25th, 2007, 11:56 am

I'm very curious to know how looks your form. :roll:
Is it possible to post a screenshot here?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby sad » May 25th, 2007, 2:17 pm

Ok, i'll post a screenshot there but i'm currently working.
The effect is not that great for the moment since my checkboxes and other stuff are not transparent so there is a gray Rectangle behind every control that are on my panels.
I'm actually trying to fix that.
Sad
sad
Active Member
Active Member
 
Posts: 5
Joined: May 24th, 2007, 2:53 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 0 guests

cron