Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Compiler error with ThemeManager #8

Open
PeterPanino opened this issue Jul 18, 2020 · 5 comments
Open

Compiler error with ThemeManager #8

PeterPanino opened this issue Jul 18, 2020 · 5 comments

Comments

@PeterPanino
Copy link

In my own project, this code generates a compiler error (although I use the same uses clause as in your demo project):

ThemeManager.ThemeType := TUThemeType(comboChooseTheme.ItemIndex);

[dcc32 Error] MainForm.pas(991): E2003 Undeclared identifier: 'ThemeManager'
[dcc32 Error] MainForm.pas(991): E2066 Missing operator or semicolon

@PeterPanino
Copy link
Author

Forgot to mention: IDE version is 10.4.

@PeterPanino
Copy link
Author

With this code, I got rid of the compiler errors and could compile the project:

procedure TformMain.comboChooseThemeSelect(Sender: TObject);
var
  ThemeManager: TUThemeManager;
begin
  ThemeManager.ThemeType := TUThemeType(comboChooseTheme.ItemIndex);
end;

But now, when I select an item in the combobox at run-time, I get an AV!!

@PeterPanino
Copy link
Author

Now I managed to eliminate the AV:

procedure TformMain.comboChooseThemeSelect(Sender: TObject);
var
  ThemeManager: TUThemeManager;
begin
  ThemeManager := TUThemeManager.Create;
  try
    ThemeManager.ThemeType := TUThemeType(comboChooseTheme.ItemIndex); // AV
  finally
    ThemeManager.Free;
  end;
end;

But it does not work like in the demo from the library: When I click on any item in the combo box, nothing happens!

@PeterPanino
Copy link
Author

PeterPanino commented Jul 19, 2020

Since the UpdateTheme method is integrated in TUForm, it does not work with TForm. Please make the UpdateTheme method UNIVERSAL to make it also work with TForm.

@srd-software
Copy link

PeterPanino, I wasn't sure what you are wanting to do, but I'd guess you want to change the UCL theme while using a regular TForm. If you do it that way the UCL components will have to all be changed in code, it won't be automatic. I played around with some code and came up with this:

uses UCL.CaptionBar, UCL.ThemeManager, UCL.Panel, UCL.Colors;
...
procedure TForm1.ComboBox1Change(Sender: TObject);
var
  ThemeManager: TUThemeManager;
begin

  ThemeManager := TUThemeManager.Create;

  try

    ThemeManager.ThemeType := TUThemeType( ComboBox1.ItemIndex );

    ThemeManager.UpdateTheme;

    UCaptionBar1.CustomBackColor.Color := UCaptionBar1.CustomBackColor.GetColor(ThemeManager);

    if ThemeManager.ThemeType = ttAuto then //use titlebar color specified by the OS
      UCaptionBar1.CustomBackColor.Color := ThemeManager.AccentColor;

    UPanel1.CustomBackColor.Color := UCaptionBar1.CustomBackColor.Color;

    //Did not seem to need this but kept it in just in case:
    //UCaptionBar1.UpdateTheme(true);
    //UPanel1.UpdateTheme(true);

  finally
    ThemeManager.Free;
  end;

end;

Note that I added a UPanel for testing as well. It seems to work OK but you'll have to update each component you want to use the theme color separately. And Vuio may have a better way to do this, but the code above works for me.

If this is not what you are wanting to do you might post what it is you need.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants