Martin
Martin

Reputation: 825

Disable a style in VCL application

I am adding the a VCL style into my application but am also giving the users an option to turn this off but I cannot figure out how to do this globally at runtime.

Setting "TStyleManager.AutoDiscoverStyleResources := false" almost works but it pops up with an error message saying "Style {style set} not found" but after dismissing the message does exactly what I want.

This code I would expect to work but does not...

if (not ParamObj.UseDarkStyle) then
begin
  //TStyleManager.AutoDiscoverStyleResources := false;
  TStyleManager.SetStyle(TStyleManager.SystemStyle);
end;

I also tried (originally)

TStyleManager.TrySetStyle('Windows');

but this also does not work.

I have tried this both sides of "Application.Initialize;" with no difference

What am I missing? Thanks in advance, Martin

Upvotes: 1

Views: 947

Answers (1)

Martin
Martin

Reputation: 825

Found the solution. There was a TStyleManager.TrySetStyle further in the initialization code that I did not notice that was resetting it back to the dark style.

Upvotes: 1

Related Questions