specialising in clinical database solutions for Australian hospitals
Posts tagged VCL Styles
Upgrade your project to Delphi XE6 and add VCL Styles to give a modern look – watch out for a few issues
Jun 27th
I have successfully migrated my very complex Delphi XE database application to Delphi XE6 after upgrading my 3rd party control sets such as Infopower, 1st Class, Devart’s UniDac, QuickReports and TMS Smooth controls.
Adding a VCL style to your application:
So I decided I would add in some VCL Styling which is extremely easy to add in – just go to Project Options, Application, Appearance, then tick the VCL styles you would like available to your application (these will be stored within the EXE), and select your Default style via the drop down box at the bottom.
The Delphi IDE writes to your project source file (the DPR file) the following: adds vcl.Themes and vcl.Styles to the Uses clause, and adds the default style to your application run code such as: TStyleManager.TrySetStyle(‘Aqua Light Slate’);
The files for the VCL Styles are located at C:\Users\Public\Documents\Embarcadero\Studio\14.0\Styles.
Don’t forget, you may be able to download Embarcadero’s “Premium Styles Pack” as part of your purchase of Delphi or RAD Studio – if so you will need to copy these to the above folder. This pack includes “Diamond”, “Jet” and “Sterling”
Let your user change style at runtime:
If you wish to allow your end users to change styles at runtime, then you can create a dialog form, place a combobox on it and add code:
Uses vcl.Themes, vcl.Styles;
procedure TdlgStyling.ComboBox1Change(Sender: TObject);
begin
TStyleManager.TrySetStyle(ComboBox1.text);
end;
procedure TdlgStyling.FormCreate(Sender: TObject);
var i:Integer;
begin
for i := 0 to High(TStyleManager.StyleNames) do
begin
ComboBox1.items.Add(TStyleManager.StyleNames[i]);
if (TStyleManager.StyleNames[i] = TStyleManager.ActiveStyle.Name) then
ComboBox1.itemIndex := i;
end;
end;
A few gotchas to take care of:
Not all controls display well with every style, so either avoid the style or turn off styling for the controls.
Things to watch out for include:
- readability of hints – especially on the 1st Class OutlookBar
- readability of coloured grid cells, especially if you set an Infopower wwDBGrid cell to pink or green and the style converts your black font to a light font.
- readability of Infopower wwDBGrid title buttons – you can set DisableThemes or DisableThemesInTitles to True.
- control brush colour will get over-ridden by styles – if you want toi ensure a particular colour is used, you will need to turn off style elements of seFont and seClient for that control, but you could probably leave seBorder active.
- you may need to make some controls larger such as radiogroups as the checkboxes may become larger with certain styles.
- some controls do not display or function correctly with styles active such as:
- TwwDBRichEditMSWord on a dialog form displays some of the background form until the scrollbar is moved by the user – thus turn OFF style elements seClient and seBorder
- TDateTimePicker – becomes a unusable mess with corruption of the form display if user tries to change date – thus turn OFF style elements seClient and seBorder
- some colour schemes will just not suit your app!
- allowing 28 of the provided styles available in your application will increase your exe size by about 1.3Mb in reality you would probably only use 1 orgive a few options at most.
Menus will get deranged if any menu items have visible = false and a VCL style is active
This is a Delphi vcl bug and applies to both TMainMenu and TPopup – items get changed in position and become associated with incorrect OnClick events!
There are a few reports posted on Quality Central indicating there are issues with DXE6 Update 1 – see http://qc.embarcadero.com/wc/qcmain.aspx?d=124944 and similar.
Menu issue workaround: The issue appears to resolve if you ensure there are no menu items with visible := false.
Access violations may occur which need sorting out:
Code which previously appeared to work flawlessly, may throw access violations as soon as you have a VCL style running
This may be happen due to some unorthodox ways forms are used – I managed to fix one of these by removing a call to a password dialog from the mainform’s OnCreate (I had it there as I used the type of log on to customise how the main form displays.
Making your own styles:
Delphi IDE includes are tool to let you do this – see Tools > Bitmap Style Designer
More information on VCL Styles:
http://docwiki.embarcadero.com/RADStudio/XE6/en/Working_with_VCL_Styles
https://code.google.com/p/vcl-styles-utils/source/browse/#svn%2Fwiki
Recent Comments