我有一个带有彩色clSkyBlue的框架,它位于一个带有面板和颜色clSkyBlue的应用程序中。该程序使用TStyleManager,它将颜色设置为当前样式。( windows10,windows10深色等)问题是,除了保留clSkyBlue的框架之外,所有东西都有正确的颜色集。
如何强制框架遵循当前选定的样式?
//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);
}发布于 2021-10-25 21:35:49
如果您需要您的TFrame在父组件更改时更改外观,请相应地设置其属性:
ParentBackground = True
ParentColor = True这还将其Color设置为clBtnFace。
我还建议不要在FormCreate中使用C++事件。使用构造函数:
__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);
}https://stackoverflow.com/questions/69714447
复制相似问题