Features of the mql4 language, subtleties and techniques - page 16

 
I hope you're friends)
 
Fast528:
I hope you're friends)

"War of the Titans" is not going to happen.

 
I hope the branch is not dead. I have the following problem: I have a 4k monitor, hence in Windows my font is enlarged (200% size). When making text objects for indicators, the text size is taken from Windows settings and also scaled, as a result if I do something that looks normal on a normal system, on my computer the text overlaps each other, and if I do normal for me, on normal settings the text is too small. I have made a setting in the indicator to let the user choose whether it is scaled or not, but I don't really like it.

Is there any way to know directly from program what font is currently in windows (enlarged or not) and make this correction in code, without touching the users? Just some people may have 4k monitor with scaled text and most of indicators (where text is used) from market looks ugly and ugly.
 
Olga Miakhovich:
I hope the thread isn't dead. I have the following problem: I have a 4k monitor, hence in Windows I have an enlarged font (size 200%). When you make text objects for indicators, the text size is taken from Windows settings and is also scaled, as a result, if you make something that looks normal on a normal system, on my computer the text overlaps each other, and if you make it normal for me, then on normal settings the text is too small. I have made a setting in the indicator to let the user choose whether it is scaled or not, but I don't really like it.

Is there any way to know directly from program what font is currently in windows (enlarged or not) and make this correction in code, without touching the users? Some people may have 4k monitor with scaled text and most of indicators (where text is used) from market looks ugly.

Maybe you should switch to working with resources, or CCanvas?

Then you can set the font size there according to the settings of the operating system.

Read about TextOut(), TextSetFont()

Документация по MQL5: Графические объекты / TextSetFont
Документация по MQL5: Графические объекты / TextSetFont
  • www.mql5.com
Устанавливает шрифт для вывода текста методами рисования и возвращает результат успешности этой операции. По умолчанию используется шрифт Arial и размер -120 (12 pt). [in]  Размер шрифта, который может задаваться положительными и отрицательными значениями. При положительных значениях размер выводимого текста не зависит от настроек размеров...
 
That's it, solution found. For those who are wondering what it is: UseTerminalInfoInteger(TERMINAL_SCREEN_DPI) function; With standard scaling it will be 96. If 2 times bigger, then the scaling will be 2 times accordingly.
 
Olga Miakhovich:
That's it, the solution is found. For those wondering what it is: Use the TerminalInfoInteger(TERMINAL_SCREEN_DPI) function; With standard scaling it will be 96. If 2 times bigger, then the scaling will be 2 times accordingly.

The solution is in the help

Example of calculating the scaling factor:

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.

 
Vladimir Pastushak:

The solution is in the help

Yeah, but it's not for fonts.

Olga Miakhovich:
That's it, the solution is found.

really? does scaling affect monitor dpi?

 
Features of ArrayResize for multidimensional arrays
void OnStart()
{
  int Array[][2];
  
  Print(ArrayResize(Array, 7)); // MQL5 - 7, MQL4 - 14
  Print(ArraySize(Array));      // 14
}
 

Forum on trading, automated trading systems and trading strategies testing

Peculiarities of mql5 language, tips and tricks

fxsaber, 2019.02.19 22:28

You see the position opened and closed at the same price. But their prices are not equal when compared without normalisation!

 
Well, yes.
Reason: