dpi reading not updating - page 3

 
Michael Charles Schefe #:

hence why i said " outcome aint unpredicable" :D

ehehehe 

Fernando Carreiro #:
No, just use the DPI. MetaTrader is a classical Windows GUI so it does not use any other metric besides the DPI.

why not

i have a font size lets say 16 

On 1280 x 1024 

when i drop down to 800x600 it looks too big , to match the same "real size" on the monitor i have to drop to 12 font size

so i think -maybe wrong- it should be a 2 step calculation (expecially since there is no way to measure the dpi across resolution changes)

[the gui is based on the font size for ease]
 
Lorentzos Roussos #:

Nice thanks 

So essentially the method is :

It looks good on this screen , what is this screen dpi 

Adapt to fit to that on other screens 

and add the resolution into the mix too somehow

best to keep to single metric dpi, and then the user can change the window size to suite. Hopefully windows does not put the borders of the window off the landscape (haha)

 
Lorentzos Roussos #: i have a font size lets say 16 

Changing the font size in the "Ease of Access" Windows panel, does not change the font size on the MetaTrader charts.

It only changes the menu and a few other elements, but not the chart (see examples below).

So if you want your graphic object text to be proportional to other chart text such as the legend text, then use only the DPI setting to scale.



 

this is the best formula i could come up with that kept a 

drawn text inside a "real life box" as consistently as possible

i guess a real test would be to have it draw a 3 cm tall text on the creators monitor and if it were 3cm on our monitors too it'd be correct.

i guess.

thanks for the tips guys

/*
The creator of a program has his screen .
It has a DPI X Y and the creator deems a specific text font size to be
the optimal one for this size.
How can we make this selection automated for all screens so that the
coder does not have to worry about setting it.
Create a class that has the specifications of the coder
*/
class CCoderScreenSpecs{
       public:
   int m_optimal_font_size;
   int m_screen_size_x;
   int m_screen_size_y;
   int m_dpi;
double m_x_by_y,m_diag_per_font_size;
       CCoderScreenSpecs(void){reset();}
      ~CCoderScreenSpecs(void){reset();}
  void reset(){
       m_optimal_font_size=0;
       m_screen_size_x=0;
       m_screen_size_y=0;
       m_dpi=0;
       m_x_by_y=0;
       m_diag_per_font_size=0.0;
       }   
       //coder sets what he sees as proper visually
  void setup(int _fs,int _dpi,int _sx,int _sy){
       m_optimal_font_size=_fs;
       m_dpi=_dpi;
       m_screen_size_x=_sx;
       m_screen_size_y=_sy;
       m_x_by_y=((double)_sx)/((double)_sy);
       double diagonal=MathSqrt(MathPow(((double)m_screen_size_x),2.0)+MathPow(((double)m_screen_size_y),2.0));
       m_diag_per_font_size=diagonal/((double)_fs);
       }
   int find_font_size(){
       int this_dpi=TerminalInfoInteger(TERMINAL_SCREEN_DPI);
       int this_wid=TerminalInfoInteger(TERMINAL_SCREEN_WIDTH);
       int this_hei=TerminalInfoInteger(TERMINAL_SCREEN_HEIGHT);
       //do an initial font size estimation 
         double diag_1=MathSqrt(MathPow(((double)this_wid),2.0)+MathPow(((double)this_wid)/m_x_by_y,2.0));
         double diag_2=MathSqrt(MathPow(((double)this_hei)*m_x_by_y,2.0)+MathPow(((double)this_hei),2.0));
         double max_diagonal=MathMax(diag_1,diag_2);
         double logical_fs=max_diagonal/m_diag_per_font_size;//
       //now the dpi comes into effect too
         double dpi_ratio=((double)this_dpi)/((double)m_dpi);
       //multiply?
         logical_fs*=dpi_ratio;
       return((int)MathRound(logical_fs));
       }
  void my_specs(){
       Print("::DPI ["+IntegerToString(TerminalInfoInteger(TERMINAL_SCREEN_DPI))+"] Width ["+IntegerToString(TerminalInfoInteger(TERMINAL_SCREEN_WIDTH))+"] Height ["+IntegerToString(TerminalInfoInteger(TERMINAL_SCREEN_HEIGHT))+"]");
       }
};
CCoderScreenSpecs LEONARDO;
int OnInit()
  {
  /* coder deems 16 pixels font size on their
     current display are proper
     Their current display is 
     96 dpi 1280 x 1024 pixels
     coder writes it permanently in the utility
  */
  ObjectsDeleteAll(0,"TEST_");
  LEONARDO.setup(16,96,1280,1024);
  int get_font_size=LEONARDO.find_font_size();
  Print("Font size to use "+IntegerToString(get_font_size));
  uint pixels[];
  uint p_width=1024;
  uint p_height=1024;
  ArrayResize(pixels,p_width*p_height,0);
  ArrayFill(pixels,0,ArraySize(pixels),ColorToARGB(clrDarkGreen,255));
  //post a text on resource at 0,0 top left
    TextSetFont("Verdana",get_font_size,FW_BOLD,0);
    TextOut("UNIT",0,0,ANCHOR_LEFT_UPPER,pixels,p_width,p_height,ColorToARGB(clrWhite,255),COLOR_FORMAT_ARGB_NORMALIZE);
    ChartRedraw(0);
  if(ResourceCreate("UNIT",pixels,p_width,p_height,0,0,p_width,COLOR_FORMAT_ARGB_NORMALIZE)){
  ObjectCreate(0,"TEST_DISPLAY",OBJ_BITMAP_LABEL,0,0,0);
  ObjectSetInteger(0,"TEST_DISPLAY",OBJPROP_XSIZE,p_width);
  ObjectSetInteger(0,"TEST_DISPLAY",OBJPROP_YSIZE,p_height);
  ObjectSetInteger(0,"TEST_DISPLAY",OBJPROP_XDISTANCE,20);
  ObjectSetInteger(0,"TEST_DISPLAY",OBJPROP_YDISTANCE,20);
  ObjectSetString(0,"TEST_DISPLAY",OBJPROP_BMPFILE,"::UNIT");
  ChartRedraw(0);
  }else{
  Print("Cannot create resource");
  }

   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
  ResourceFree("::UNIT");
  }

 
however if a user has a dual monitor that is registered as extra screen width by mt5 and it breaks the formula
 
Lorentzos Roussos #:
however if a user has a dual monitor that is registered as extra screen width by mt5 and it breaks the formula

you mean like mine 2560 x 1080 -- aspect 21:9 or ones at work with aspect 32:9? (haha)

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
 
Michael Charles Schefe #:

you mean like mine 2560 x 1080 -- aspect 21:9 or ones at work with aspect 32:9? (haha)

he means. if you have two monitors with different specifications the images on the second monitor may not match what you see in the first monitor.

 
My approach has been scale the controls not font size, because font size is set in points, what means it will look same in any screen. what need be adjusted is the controls to match the font size. Just like is in the documentations as  Fernando Carreiro already commented here.
 
if you try to scale the font size you have another problem which is for proper scaling you should be able to set float value for font size, what is not allowed in MQL for the standard controls/objects.