Example of scaling factor calculation:
|
//--- Creating a 1.5 inch wide button on a screen
int screen_dpi = TerminalInfoInteger(TERMINAL_SCREEN_DPI); // Find DPI of the user monitor
int base_width = 144; // The basic width in the screen points for standard monitors with DPI=96
int width = (button_width * screen_dpi) / 96; // Calculate the button width for the user monitor (for the specific DPI)
...
//--- Calculating the scaling factor as a percentage
int scale_factor=(TerminalInfoInteger(TERMINAL_SCREEN_DPI) * 100) / 96;
//--- Use of the scaling factor
width=(base_width * scale_factor) / 100;
|
In the above example, the graphical resource looks the same on monitors with different resolution characteristics.
The size of control elements (buttons, dialog windows, etc.) corresponds to personalization settings.
发表评论