I have a frame, with color clSkyBlue, which sits in an application with panels and various things with the color clSkyBlue. The program uses TStyleManager this sets the color to the current style. (ie windows10,windows10 dark etc). The problem is that everything has the correct color set from the stylemanager except for the frame which remains clSkyBlue.
How do I force the frame to follow the current style selected?
//in the main form code
void __fastcall TMainFormUnit::FormCreate(TObject *Sender)
{
...
for (int i = 0; i < TStyleManager::StyleNames.Length; i++)
cbxVclStyles->Items->Add(TStyleManager::StyleNames[i]);
TStyleManager::TrySetStyle(TStyleManager::StyleNames[1]);
...
}
//---------------------------------------------------------------------------
void __fastcall TMainFormUnit::cbxVclStylesChange(TObject *Sender)
{
TStyleManager::SetStyle(cbxVclStyles->Text);
}
If you need your TFrame
to change appearance as the parent component changes, set its properties accordingly:
ParentBackground = True
ParentColor = True
This will also set its Color
back to clBtnFace
.
I also recommend not using the FormCreate
event in C++. Use the constructor:
__fastcall TMainFormUnit::TMainFormUnit(TComponent* Owner)
: TForm(Owner)
{
cbxVclStyles->Items->AddStrings(TStyleManager::StyleNames);
}
//---------------------------------------------------------------------------
void __fastcall TMainFormUnit::cbxVclStylesChange(TObject *Sender)
{
TStyleManager::TrySetStyle(static_cast<TComboBox*>(Sender)->Text);
}