C++Builder Learn To Modernize Appearance Of Windows VCL Applications By Using Powerful Styles

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,203
Credits
4,034
Learn To Modernize Appearance Of Windows VCL Applications By Using Powerful Styles
March 1, 2021 By Yilmaz Yoru

Syles are sets of graphical details that define the look and feel of a application visually and they are one of most beautiful and useful UI feature of RAD Studio, that makes your UI elements skinned with professionally designed with different Styles. Official Styles are designed by Embarcadero’s Designers and other there are other 3rd party Styles, also users may generate their own styles. Styles are similar to themes in Windows or skins of applications. Styles are being modernized with RAD Studio, C++ Builder and Delphi since the first XE versions (2010), currently C++ Builder 10.4 has many improvements on Styles.

In RAD Studio, VCL Для просмотра ссылки Войди или Зарегистрируйся Projects, using styles on your New Projects is very easy. You design your application view in normal ways with buttons, labels, edit boxes, memos, trackbars, panels, switches etc. You can also add these Styles to your Old C++ Builder Projects or to Old C++ Builder Unit files. You just need a RAD Studio, C++ Builder which supports styles, we highly recommend you latest RADS , C++ Builder 10.x versions which has new features and improvements on Styles.

Для просмотра ссылки Войди или Зарегистрируйсяis a revolutionary Multi-Device Development. Devices are everywhere and users’ expectations are higher than they have ever been. Customers expect to be able to use an application on their smartphone while on the go and then switch to their tablet or Desktop computer while in their office or at home. Optimizing user interfaces for each of these device form factors can be challenging and costly, effectively building multiple separate form views for each device. More details about FireUI and Styles can be found Для просмотра ссылки Войди или Зарегистрируйся and some Premium Styles can be found Для просмотра ссылки Войди или Зарегистрируйся
1614672384252.png
A style permits you to change the appearance of every part and state of a control (buttons, edit boxes, lists, panels, trackbars, checkboxes every official component has a style). VCL controls are made up of parts and states. A VCL style consists of a set of values for each of these parts and states. For instance, a scroll bar has the following parts: frame, slider, and the two side buttons for each direction. The side buttons, for example, have the following states: pressed, disabled, hot, normal.

Styles can be found in “C:\Users\Public\Documents\Embarcadero\Studio\ …<version>…\Styles” folder, please check “C:\Users\Public\Documents\Embarcadero\Studio” for the “Styles” folder. You can also manually get many new (about 40+) Styles by using GetIt Package Manger via Tools->GetIt Package Manager Menu of RAD Studio.
1614672410077.png
To use Styles on your new C++ Builder Project, go to Tools -> Project Options Menu and go to Application -> Appearance Section. You will see list of Custom Styles installed in Application settings, to apply these just check which style or styles you want to use on your application. Set your Default Style.
1614672423488.png
There is a good wiki about Для просмотра ссылки Войди или Зарегистрируйся. RAD Studio, C++ Builder comes with is a Bitmap Style Designer application in Tools -> Bitmap Style Designer that enables you to Create, edit, and test VCL styles (.vsf files) and FMX styles (.style). It can converts .vsf files to .styles too. You can edit styles with Для просмотра ссылки Войди или Зарегистрируйся.

If you set your Default Style, your application UI will run with this style. If you select and include your styles from options, you can directly apply one of these styles to your application on runtime by using SetStyle(…) or TrySetStyle(…) commands , as given below.
Код:
Vcl::Themes::TStyleManager::SetStyle("Carbon");
or
Код:
Vcl::Themes::TStyleManager::TrySetStyle("Carbon",false);
Here note that Default Style is “Windows” and it is added into style list as defult. This feature will improve visual quality of your application, you can also allow users to choice their UI appearance. Some users may use different styles in different day times ( like dark mode or light mode), or season based styles or their styles may depend on their mood. This ability to select styles by user preferences, will rich your application view.

Example below shows how to add selected styles of a project to a combobox items.
C++:
//---------------------------------------------------------------------------
 
#include <vcl.h>
//#include <Vcl.Styles.hpp>
#pragma hdrstop
 
#include "Styles_VCL_Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
 ComboBox1->Items->BeginUpdate();
 try
 {
 ComboBox1->Items->Clear();
 DynamicArray<String> styles = Vcl::Themes::TStyleManager::StyleNames;
 
 for(int i = 0; i < styles.Length; ++i)
 {
 ComboBox1->Items->Add(styles[i]);
 }
 }
 __finally
 {
 ComboBox1->Items->EndUpdate();
 }
 
 ComboBox1->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
 Vcl::Themes::TStyleManager::TrySetStyle(ComboBox1->Items->Strings[ComboBox1->ItemIndex],false);
          // Vcl::Themes::TStyleManager::SetStyle("Windows");
}
//---------------------------------------------------------------------------
This example above is explained well Для просмотра ссылки Войди или Зарегистрируйся on Mr.David Intersimone’s blogposts. If you are using RAD Studio or C++ Builder 10.x or below, there are some old post and videos explains how to use VCL styles. These posts may be helpful to both C++ Builder and Delphi users;

Using C++Builder to list all available VCL styles in a ComboBox and apply a selected style using the ComboBoxChange event
Для просмотра ссылки Войди или Зарегистрируйся

Learn To Use Styles To Create Visual Stunning VCL And FireMonkey Apps With Delphi/C++ Builder
Для просмотра ссылки Войди или Зарегистрируйся

VCL Styles in Delphi, C++Builder and RAD Studio XE2

Learn Useful Hints For Working With Styles To Build Visually Stunning Windows Applications
Для просмотра ссылки Войди или Зарегистрируйся