![104dualmonitor | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/08/104dualmonitor-scaled.jpg?resize=1140%2C694&ssl=1)
Many times we need to override windows default settings or customize our application by code, irrespective of user settings in windows for better user experience. Your application has been built with options to apply certain themes and the user also has the flexibility to change Windows themes for entire windows/apps. In this case, your application user experience should not be affected by user system settings. This post can guide you to set the themes in your Windows VCL application.
How to check whether dark mode is enabled?
- Press Windows + R -> Type Regedit cmd in Run Command window.
- Navigate to the folder: Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize.
- Check AppsUseLightTheme Keyword and if its value is 1 then the windows apps theme is in Light mode and 0 means it’s in Dark mode.
How to set the themes in Delphi from project options :
In Delphi IDE, Go to -> Project Menu -> options -> appearance -> Select the available themes suitable for your application. Carbon for Dark theme for example.
You application theme settings:
If you want to give a better user experience explicitly irrespective of (or) according to windows themes selected by the user in the machine, first programmatically check the app theme mode. Navigate to the following location Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize and get the keyword AppsUseLightTheme value. Accordingly build your logic of setting the VCL theme using the VCL API to set the themes.
Note: Platform specific conditional defines need to be included accordingly if it is cross platform application.
Check the below Video for the full demonstration of setting the dark/light theme Vice-versa for a VCL application.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
hi, please c++ Dark And Light Themes mode share.I don’t know how to use these features in borland c ++.
You would need to upgrade to a more recent version of C++Builder. None of the old Borland editions have this feature.
I have migrated a delphi 7 to delphi alexandria 11 but now when I activate the Themes it gives me this message
[Window Title]
Error
[Content]
Style ‘Carbon’ not found
[Close]
how can I fix it?
BTW it works if I create a new VCL app
Go to project options for the project which has the problem, then choose appearance, and then custom styles. Deselect Carbon. The reason for the message is the Carbon custom style was previously installed in that project and you don’t have it installed or the path has changed now.