What impact video card / monitor resolution have on graphical objects?

 

Hi all, I created a dashboard for my expert advisor using graphical objects. I decided each object's position and size using OBJPROP_XDISTANCE, OBJPROP_YDISTANCE, OBJPROP_XSIZE, OBJPROP_YSIZE.
Since monitors with different resolutions are not available, I wanted to understand if in some way the resolution can impact on the position of the objects on the chart? (and if so, how can you get around this?) I've had problems in the past with a freelancer who built a dashboard for me that had some issues on some monitors.

Thanks!

 

Forum on trading, automated trading systems and testing trading strategies

Graphical Interfaces and Windows scaling in high res screens.

Fernando Carreiro, 2021.05.30 21:10

Have a look at the documentation regarding the terminal property "TERMINAL_SCREEN_DPI" and also do a search in the forum with that keyword.

TERMINAL_SCREEN_DPI

The resolution of information display on the screen is measured as number of Dots in a line per Inch (DPI).

Knowing the parameter value, you can set the size of graphical objects so that they look the same on monitors with different resolution characteristics.

int

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.


Since my previous post references the MQL5 documentation, here are the relevant references for the MQL4 documentation ...

TerminalInfoInteger

Returns an integer value of a corresponding property of a running mql4 program

TERMINAL_SCREEN_DPI

The resolution of information display on the screen is measured as number of Dots in a line per Inch (DPI).

TerminalInfoInteger

TERMINAL_SCREEN_DPI

The resolution of information display on the screen is measured as number of Dots in a line per Inch (DPI).

Knowing the parameter value, you can set the size of graphical objects so that they look the same on monitors with different resolution characteristics.

int

TerminalInfoInteger - Checkup - MQL4 Reference
TerminalInfoInteger - Checkup - MQL4 Reference
  • docs.mql4.com
TerminalInfoInteger - Checkup - MQL4 Reference
 

You need to check the DPI used and adjust your objects to deal with it.

See TERMINAL_SCREEN_DPI

https://www.mql5.com/en/docs/constants/environment_state/terminalstatus

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Client Terminal Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Client Terminal Properties
  • www.mql5.com
Client Terminal Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Thanks so much for the replies! I will thoroughly study the codes and integrate them with objects. Do you know if there is a way to test various resolutions in Windows without actually needing the Monitor/video card?