Hi,
I have displayed from the chart a text via OBJ_LABEL:
And I have added a background via the OBJ_RECTANGLE_LABEL
After testing this code in different computers I notice that the background keeps the same size however the text can have different sizes. How is possible and how to resize the background based on the current text size ?
Thanks for your help
Regards,
Dorian
Hello,
Text is subject to screen DPI, as set in Windows. In MQL5 there is TERMINAL_SCREEN_DPI to get you going; maybe there is for MQL4 as well, but I can not recall.
thank you. Do you have an example of code to scale font size based on DPI ?
Regards,
Dorian
Hello,
TerminalInfoInteger(TERMINAL_SCREEN_DPI) will return the number (or close to) set on Windows/Settings/System/Display. So, e.g. it could be 144 if we have set 150 in Windows.
Another point to have in mind is that the text that MQL outputs with the OBJ_LABEL is scaled. That means that if we specify a font size of 8, it will have a size of 12 pixels. So, we have to alter the size of OBJ_RECTANGLE_LABEL our selves, e.g.
ObjectSetInteger(0, name, OBJPROP_YSIZE, (int)100*TerminalInfoInteger(TERMINAL_SCREEN_DPI)*.01);
regards
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have displayed from the chart a text via OBJ_LABEL:
And I have added a background via the OBJ_RECTANGLE_LABEL
After testing this code in different computers I notice that the background keeps the same size however the text can have different sizes. How is possible and how to resize the background based on the current text size ?
Thanks for your help
Regards,
Dorian