Mark- 34 Posted yesterday at 12:20 AM (edited) Hello, I provide the user a menu to select a desired style for the application. I have tested most styles and have trouble with only one, named “Windows”. As an example: Ruby Graphite Windows The window color for the text is wrong. Here is the code to fetch the background color and font color: procedure TDrawingSurface2.GetStyleColors(out bgColor, fColor: TColor); var actStyle:TCustomStyleServices; begin actStyle:=TStyleManager.ActiveStyle; if Assigned(actStyle) and actStyle.Enabled then begin bgColor:=actStyle.GetStyleColor(scWindow); fColor:=actStyle.GetStyleFontColor(sfWindowTextNormal); end else begin bgColor:=clWindow; fColor:=clWindowText; end; end; The else is never triggered. I can check for the style name “Windows” and return: bgColor:=clWindow; fColor:=clWindowText; and the dialog is correct. Any ideas? Thanks, Mark Edited yesterday at 12:30 AM by Mark- Share this post Link to post
Remy Lebeau 1620 Posted 23 hours ago (edited) TStyleManager.ActiveStyle will never return nil. If there is no style assigned then it returns the TStyleManager.SystemStyle (the Vcl.Themes.TUxThemeStyle class). TUxThemeStyle.Enabled returns True if the Win32 uxtheme.dll is successfully loaded and your app is manifested for ComCtrl32 v6. So, this is likely why your 'else' is never triggered. TUxThemeStyle.DoGetStyleColor(scWindow) returns clBtnFace, not clWindow as you are expecting. The style colors which return clWindow are: scComboBox scComboBoxDisabled scEdit scEditDisabled scGrid scListBox scListBoxDisabled scListView scTreeView TUxThemeStyle.DoGetStyleFontColor(sfWindowTextNormal) does return clWindowText, as expected. In any case, is your Label not simply set to Transparent=True or ParentColor=True? Edited 23 hours ago by Remy Lebeau 1 Share this post Link to post
Mark- 34 Posted 23 hours ago (edited) Thanks for the response Remy. OK I can trim down the code. The text is drawn on a TCustomPanel. I am creating the dialog to replace MessageDlg. Styling is the last test. What confuses me is TUxThemeStyle.DoGetStyleColor(scWindow) works for all styles I tested, 10 or so, except one, "Windows". So, I will test with using another selector. I tested all the selectors, above, with Ruby Graphite and all returned the wrong color: Interesting... Edited 11 hours ago by Mark- Share this post Link to post
MarkShark 27 Posted 11 hours ago I may be misunderstanding the issue, but I use (Style).IsSystemStyle to check for the "Windows" style. Share this post Link to post
Mark- 34 Posted 11 hours ago (edited) 7 minutes ago, MarkShark said: I may be misunderstanding the issue, but I use (Style).IsSystemStyle to check for the "Windows" style. Thanks for the response. The issue is: bgColor:=actStyle.GetStyleColor(scWindow); returns the correct color for all styles I tested, 10 or so, except one, "Windows". Edited 11 hours ago by Mark- Share this post Link to post
Uwe Raabe 2165 Posted 11 hours ago 36 minutes ago, Mark- said: returns the correct color for all styles I tested, 10 or so, except one, "Windows". That depends on the definition of correct. 1 Share this post Link to post
Mark- 34 Posted 10 hours ago 7 minutes ago, Uwe Raabe said: That depends on the definition of correct. See the examples above. Correct as in the color returned is the same, or not, as the color of the window. Share this post Link to post
Uwe Raabe 2165 Posted 10 hours ago (edited) 45 minutes ago, Mark- said: Correct as in the color returned is the same, or not, as the color of the window. See here: 13 hours ago, Remy Lebeau said: TUxThemeStyle.DoGetStyleColor(scWindow) returns clBtnFace, not clWindow as you are expecting. Update: You can see what colors are returned here: function TUxThemeStyle.DoGetStyleColor(Color: TStyleColor): TColor; begin case Color of scBorder: Result := clWindowFrame; scButtonDisabled: Result := clBtnFace; scButtonFocused: Result := clBtnFace; scButtonHot: Result := clBtnFace; scButtonNormal: Result := clBtnFace; scButtonPressed: Result := clBtnFace; scCategoryButtons: Result := clBtnFace; scCategoryButtonsGradientBase: Result := $C0C0C0; scCategoryButtonsGradientEnd: Result := $F0F0F0; scCategoryPanelGroup: Result := clMedGray; scComboBox: Result := clWindow; scComboBoxDisabled: Result := clWindow; scEdit: Result := clWindow; scEditDisabled: Result := clWindow; scGrid: Result := clWindow; scGenericBackground: Result := clBtnFace; scGenericGradientEnd: Result := $C0C0C0; scGenericGradientBase: Result := $F0F0F0; scHintGradientBase: Result := clInfoBk; scHintGradientEnd: Result := clInfoBk; scListBox: Result := clWindow; scListBoxDisabled: Result := clWindow; scListView: Result := clWindow; scPanel: Result := clBtnFace; scPanelDisabled: Result := clBtnFace; scSplitter: Result := clWhite; scToolBarGradientBase: Result := $C0C0C0; scToolBarGradientEnd: Result := $F0F0F0; scTreeView: Result := clWindow; scWindow: Result := clBtnFace; else Result := clNone; end; end; Edited 10 hours ago by Uwe Raabe add reference code 1 Share this post Link to post
Remy Lebeau 1620 Posted 10 hours ago 1 hour ago, Mark- said: The issue is: bgColor:=actStyle.GetStyleColor(scWindow); returns the correct color for all styles I tested, 10 or so, except one, "Windows". Feel free to file a bug report. Share this post Link to post
Mark- 34 Posted 9 hours ago 42 minutes ago, Uwe Raabe said: TUxThemeStyle.DoGetStyleColor(scWindow) returns clBtnFace, not clWindow as you are expecting. You mean what all the other styles return, I guess I am confused. Perhaps I am all wet, 10 are correct, one is incorrect; the 1 seems to be the issue. Share this post Link to post
Mark- 34 Posted 9 hours ago 38 minutes ago, Remy Lebeau said: Feel free to file a bug report. Sure. Share this post Link to post
Uwe Raabe 2165 Posted 8 hours ago What type of control is the Parent of the label (TForm, TPanel,...)? Share this post Link to post
Mark- 34 Posted 8 hours ago 6 minutes ago, Uwe Raabe said: What type of control is the Parent of the label (TForm, TPanel,...)? The text is drawn on a TCustomPanel. The custom panel is on the form (TForm). Share this post Link to post
Remy Lebeau 1620 Posted 5 hours ago 3 hours ago, Mark- said: The text is drawn on a TCustomPanel. The custom panel is on the form (TForm). Did you try ParentBackground=True on the Panel? Then you would set only the Form's color and the Panel would pick up the same color. Share this post Link to post
Uwe Raabe 2165 Posted 5 hours ago A TCustomPanel is not filled with a color, but with part of the style bitmap (defined in the GroupBox.Frame object). In a lot of cases this may be similar to a solid color, but it can as well be some texture or even a transparent area for some styles like Amakrits. You might really get the best results with setting the labels Transparent property to True. Share this post Link to post
Mark- 34 Posted 3 hours ago (edited) 2 hours ago, Remy Lebeau said: Did you try ParentBackground=True on the Panel? Then you would set only the Form's color and the Panel would pick up the same color. Yes. ParentBackground state made no difference. The form color is set to clWindow. Edited 2 hours ago by Mark- Share this post Link to post
Mark- 34 Posted 2 hours ago (edited) 3 hours ago, Uwe Raabe said: A TCustomPanel is not filled with a color, but with part of the style bitmap (defined in the GroupBox.Frame object). In a lot of cases this may be similar to a solid color, but it can as well be some texture or even a transparent area for some styles like Amakrits. You might really get the best results with setting the labels Transparent property to True. I "FillRect" the canvas of the panel, with the color returned by the style manager. There is not a label. I DrawText the text on the canvas. Amakrits style works. Edited 2 hours ago by Mark- Share this post Link to post