Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFrame color issue



Permlink Replies: 5 - Last Post: Feb 29, 2016 12:15 PM Last Post By: Remy Lebeau (Te...
Doug Hay

Posts: 122
Registered: 5/26/05
TFrame color issue
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 5:16 PM
Why doesn't this code set the color of a TFrame? I couldn't get the TFrame to change color, so I put a TPanel on it, and I can't change it's color either

pFrameInstantTQ = new TFrameInstantTQ(NULL); // Can go on different panels that are in different forms

pFrameInstantTQ->Name = "InstantTQ1";

pFrameInstantTQ->Parent = FormTQ2014->PanelMain;

pFrameInstantTQ->Top = 0;
pFrameInstantTQ->Left = 0;

pFrameInstantTQ->Color = clLime; // Doesn't work
pFrameInstantTQ->PanelMain->Color = clLime; // Doesn't work
pFrameInstantTQ->LabelName->Font->Color = clMoneyGreen; // Works

pFrameInstantTQ->Show();

Thanks!
Doug
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: TFrame color issue
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2016 10:52 PM   in response to: Doug Hay in response to: Doug Hay
Doug Hay wrote:
Why doesn't this code set the color of a TFrame? I couldn't get the TFrame to change color, so I put a TPanel on it, and I can't change it's color either

pFrameInstantTQ = new TFrameInstantTQ(NULL); // Can go on different panels that are in different forms

pFrameInstantTQ->Name = "InstantTQ1";

pFrameInstantTQ->Parent = FormTQ2014->PanelMain;

pFrameInstantTQ->Top = 0;
pFrameInstantTQ->Left = 0;

pFrameInstantTQ->Color = clLime; // Doesn't work
pFrameInstantTQ->PanelMain->Color = clLime; // Doesn't work
pFrameInstantTQ->LabelName->Font->Color = clMoneyGreen; // Works

pFrameInstantTQ->Show();

Thanks!
Doug

ParentColor and ParentBackground should also be set to false to have the color
property take effect.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TFrame color issue
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 29, 2016 11:25 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff wrote:

ParentColor and ParentBackground should also be set to false
to have the color property take effect.

Setting the Color property automatically sets the ParentColor property to
false, and also sets the ParentBackground property to false if the Color
property is being set at design-time.

--
Remy Lebeau (TeamB)
Doug Hay

Posts: 122
Registered: 5/26/05
Re: TFrame color issue
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 29, 2016 11:29 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Thank you Jeff. Both of those items are = false in my object inspector. But if I manually add the code it works, Why is that?

Thanks!

Jeff Overcash (TeamB) wrote:
Doug Hay wrote:
Why doesn't this code set the color of a TFrame? I couldn't get the TFrame to change color, so I put a TPanel on it, and I can't change it's color either

pFrameInstantTQ = new TFrameInstantTQ(NULL); // Can go on different panels that are in different forms

pFrameInstantTQ->Name = "InstantTQ1";

pFrameInstantTQ->Parent = FormTQ2014->PanelMain;

pFrameInstantTQ->Top = 0;
pFrameInstantTQ->Left = 0;

pFrameInstantTQ->Color = clLime; // Doesn't work
pFrameInstantTQ->PanelMain->Color = clLime; // Doesn't work
pFrameInstantTQ->LabelName->Font->Color = clMoneyGreen; // Works

pFrameInstantTQ->Show();

Thanks!
Doug

ParentColor and ParentBackground should also be set to false to have the color
property take effect.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: TFrame color issue
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 29, 2016 11:55 AM   in response to: Doug Hay in response to: Doug Hay
Doug Hay wrote:
Thank you Jeff. Both of those items are = false in my object inspector. But if I manually add the code it works, Why is that?

Thanks!

Usually it is a property editor handling that. Remy looked deeper than I did
and says that setting the Color automatically set the ParentColor to false, but
the other half looks like it is a property editor handling setting it to false
at design time.

I only tested it by setting the color then looking at the TFrame's DFM to see
what changes and saw both changes and didn't investigate further to see if any
did it as a side effect of setting Color on its own.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TFrame color issue
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 29, 2016 12:15 PM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff wrote:

Usually it is a property editor handling that. Remy looked deeper
than I did and says that setting the Color automatically set the
ParentColor to false, but the other half looks like it is a property
editor handling setting it to false at design time.

Actually, it is the Color property setter itself which is doing that. It
sets the ParentBackground only at design-time:

procedure TControl.SetColor(Value: TColor);
begin
  if FColor <> Value then
  begin
    FColor := Value;
    FParentColor := False;
    if (csDesigning in ComponentState) and not (csReading in ComponentState) 
and (Self is TWinControl) then
      TWinControl(Self).ParentBackground := False;
    Perform(CM_COLORCHANGED, 0, 0);
  end;
end;


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02