Search the Community
Showing results for tags 'styles'.
Found 4 results
-
I've got a Delphi 12.1 VCL application where, by default, there is no style applied. If the user wants, they can switch to a dark mode at which point, I load a pre-selected .vsf file and all is good. If the user wants to switch back, I simply set the style to 'Windows' and it switches back to the default style. It all still works. Because there will be several programs with this same functionality and option, I don't store the style file in the application but load it dynamically at runtime. And if, down the road, I want to replace the style file with a different one, I can because it's named simply "DarkMode.vsf" even though the internal style name could be "CopperDark" or "Windows10 BlackPearl" for example. With the overloaded TStyleManager.SetStyle procedure that can take either a string (the style name) or a TStyleServicesHandle (returned from LoadFromFile), I figured I could use either one interchangeably; therefore, it's simplest in my code to refer to the loaded file by its handle and not it's name but when changing back to the default style, I simply use the standard 'Windows' string name, leading to these procedures: procedure TMainForm.LoadThemeFiles; begin // save handle to dark style for later FDarkStyleServicesHandle := TStyleManager.LoadFromFile(TPath.Combine(ThemePath, 'DarkMode.vsf')); end; procedure TsMainForm.SetDarkTheme; begin TStyleManager.SetStyle(FDarkStyleServicesHandle); end; procedure TcssMainForm.ClearTheme; begin TStyleManager.SetStyle('Windows'); end; However, I found that once SetDarkTheme has been called followed by ClearTheme, SetDarkTheme will no longer work (as in the case the user switches DarkMode off then tries to turn it back on). I've attached a small program to demonstrate this; I've tried it in both Delphi 11.3 and 12.1. I've submitted a bug report but also have a work-around. Since SetStyle(string-name) works consistently, I've changed the LoadThemeFiles procedure to get and save the name of the style. The TStyleManager has a list of all registered style names, including 'Windows' so if I load one style, TStyleManager should have two style names: procedure TsMainForm.LoadThemeFiles; var StyNames: TArray<string>; begin TStyleManager.LoadFromFile(TPath.Combine(ThemePath, 'DarkMode.vsf')); StyNames := TStyleManager.StyleNames; // reminder not to load any styles into the project if Length(StyNames) > 2 then raise EProgrammerNotFound.Create('Styles should not be defined in the project!'); for var sn in StyNames do begin if not SameText(sn, 'Windows') then begin // save the dark-mode style name FDarkStyleName := sn; Break; end; end; end; After that, the change to SetDarkMode procedure is pretty obvious: procedure TcssMainForm.SetDarkTheme; begin TStyleManager.SetStyle(FDarkStyleName); end; I looked at the VCL source for the two SetStyle procedures and the string version simply looks through the list of registered style names and calls the TStyleServicesHandle version. So why does the first method fail? VclStyleToggle.zip
-
I have a problem with delphi ios controls that i do not know why?! I have created a simple project on Delphi 11.2 and (test run Delphi 11.3) with some controls: TTabControl, TEdit, TCombobox, TMemo, TButton... 1. When i run this project on iPhone 11 device with iOS 16 then everything is OK 2. However, when i run this project on iPhone 14 device with iOS 16, then controls have not show on the form (I have attached two screen images of this sample) My Mac: MacBook Pro 2020, Intel Core i7, Moneterey OS, XCode 14 Please help me, thanks!
- 12 replies
-
I'v made an iOS app where I want the user to select the style. In the deployment I have added some fsf-files which have a Remote Path set to StartUp\Documents The style is set via the following code: astylefile := TPath.Combine(TPath.GetDocumentsPath, 'BlackRock_iOS.fsf'); TStyleManager.SetStyleFromFile(astylefile); Then I get the error: Cannot open file "/var/mobile/containers/Data/Application/.../Documents/BlackRock_iOS.fsf". No such file or directory. If I inspect the file appname.app, the folder StartUp/Documents is present with the fsf-files in it, so the files are deployed. Thus something prevents my app to access the files? I tried the same in a blank iOS app, where the styles are applied successful. Anybody an idea of what could be wrong?
-
Hello guys, Here is the v2 of my ImmersiveColors project: Added FPC and lazarus support. Replaced TImmersiveColors class with a simplified functions: GetImmersiveColorSetCount, GetImmersiveColor, GetActiveImmersiveColor, ... Added default return value to make the library work on platform that do not have immersive colors support (XP, Win7, macOS, ...). Added many new function such as IsDarkThemeActive, GetRivalColorType,... Added three new components : TImmersiveColorsListBox, TImmersiveColorSetListBox, TImmersiveNotify. Improved Explorer. You can find the v2 on the "next" branch : https://github.com/MahdiSafsafi/ImmersiveColors/tree/next