Comment text lines overlap

 

I set up a new VM with MT4 and on this when I use Comment("something") the lines are overlapping, e.g. below. I have a workaround which is to change Windows 10 trying to "fix" blurry displays. It does make the RDP session look very crisp and lovely, *but*, MT4 ends up looking garbled as per this:

Question for you all - is there a snippet of code out there, that can be dropped in as a replacement to Comment() that allows for better font size and font type controls? Thanks and good luck :)

 

To answer your question - yes, there is code out there that will allow you to choose you own font and controls but that is quite complicated compared to just fixing your resolution problem.


Try right clicking on the terminal.exe file and selecting properties. Select the compatibility tab and look for "Change high DPI settings" button towards the bottom. That will bring up a dialogue with 2 check boxes that you can tick and a drop down where you select "I open this program"


Try that, restart your terminal and see if it helps.

 
Kenneth Hubbard #:

To answer your question - yes, there is code out there that will allow you to choose you own font and controls but that is quite complicated compared to just fixing your resolution problem.


Try right clicking on the terminal.exe file and selecting properties. Select the compatibility tab and look for "Change high DPI settings" button towards the bottom. That will bring up a dialogue with 2 check boxes that you can tick and a drop down where you select "I open this program"


Try that, restart your terminal and see if it helps.

I don't mind complexity, but my hope was a function I can load with include, and just do AltComment("stuff", "courier", 12); for example. I might just have to write it myself... But I've yet to discover how to program chart objects, and time is expensive! Fixing windows resolution is turning out to be a complete PITA, I'm either getting my full macbook retina resolution which looks great, but I need a magnifying glass to see anything on the screen. Or if I turn off the DPI fixing, it's back to twice the size, e.g. everything is huge (double to be sure), and I'd say almost half of the screen area is occupied by borders and buttons as I have 20 charts visible when I trade. I'm working on a shell script that will arrange the windows via profile and charts0x files, this should work, and think I can minimize the screen waste quite well this way. I can also, I think, get 7 windows across, and 3 down, instead of the default 5x4 tiling, which IMO is wasteful in terms of screen usage.

Good luck all :)

 
jepper #:

I don't mind complexity, but my hope was a function I can load with include, and just do AltComment("stuff", "courier", 12); for example. I might just have to write it myself... But I've yet to discover how to program chart objects, and time is expensive! Fixing windows resolution is turning out to be a complete PITA, I'm either getting my full macbook retina resolution which looks great, but I need a magnifying glass to see anything on the screen. Or if I turn off the DPI fixing, it's back to twice the size, e.g. everything is huge (double to be sure), and I'd say almost half of the screen area is occupied by borders and buttons as I have 20 charts visible when I trade. I'm working on a shell script that will arrange the windows via profile and charts0x files, this should work, and think I can minimize the screen waste quite well this way. I can also, I think, get 7 windows across, and 3 down, instead of the default 5x4 tiling, which IMO is wasteful in terms of screen usage.

Good luck all :)

void CommentDropIn( string text, string fontname="Consolas Bold", int fontsize=10 )
  {
   string _text[];
   StringSplit(text,StringGetCharacter("\n",0),_text);
      
   for (int i=0;i<ArrayRange(_text,0);i++)
     {
      ObjectCreate(string(i), OBJ_LABEL, 0, 0, 0, 0);
      ObjectSet(string(i), OBJPROP_XDISTANCE, fontsize * 0.5 );
      ObjectSet(string(i), OBJPROP_YDISTANCE, ( (fontsize * 1.5) * i ) + (fontsize * 1.5) );
      ObjectSetText(string(i), _text[i], fontsize, fontname, White);
     }
  }
I wrote this, to be used in place of Comment.
 
jepper #:
I wrote this, to be used in place of Comment.
Text using above is truncated at 64 length, ok so I guess I have to do another string split and create adjecent blocks of 64 length objects on the x-axis... Not an issue per se, but, is there a better way, anyone? It might prove difficult with variable width fonts, but maybe I can obtain the width of each object at run time.
 
jepper #:
I wrote this, to be used in place of Comment.
This is a great function, exactly what I was looking for.  Good job. Thanks
 

Is it possible to create two comments in one line?

I was trying this, but the secondary one is erasing the first one.

//+------------------------------------------------------------------+
//|         C  O  M  M  E  N  T     D  R  O  P      I  N             |
//+------------------------------------------------------------------+
void CommentDropIn(string text, string fontname="Consolas Bold", int font_s=12)
  {
   string _text[];
   StringSplit(text,StringGetCharacter("\n",0),_text);
   for(int i=0; i<ArrayRange(_text,0); i++)
     {
        {ObjectCreate(string(i), OBJ_LABEL, 0, 0, 0, 0); ObjectSet(string(i), OBJPROP_XDISTANCE, font_s * 0.5);}
        {ObjectSet(string(i), OBJPROP_YDISTANCE, ((font_s * 1.5) * i) + (font_s * 1.5)); ObjectSetText(string(i), _text[i], font_s, fontname, White);}
     }
  }
//+------------------------------------------------------------------+
//|        C  O  M  M  E  N  T     D  R  O  P      I  N     2        |
//+------------------------------------------------------------------+
void CommentDropIn2(string text2, string fontname2="Consolas Bold", int font_s2=12)
  {
   string _text2[];
   StringSplit(text2,StringGetCharacter("\n",0),_text2);
   for(int u=0; u<ArrayRange(_text2,0); u++)
     {
        {ObjectCreate(string(u), OBJ_LABEL, 0, 0, 0, 0); ObjectSet(string(u), OBJPROP_XDISTANCE, font_s2 * 0.5+600);}
        {ObjectSet(string(u), OBJPROP_YDISTANCE, ((font_s2 * 1.5) * u) + (font_s2 * 1.5)); ObjectSetText(string(u), _text2[u], font_s2, fontname2, White);}
     }
  }

 
losdelamos #:

Is it possible to create two comments in one line?

I was trying this, but the secondary one is erasing the first one.

You should not use the same names for label objects in both functions, i.e. 0, 1, 2, etc. Use a prefix for the name to distinguish them. And also define the name for the object as a variable once per iteration to avoid unnecessary repetition of code. Example:

string name="DropIn1_"+IntegerToString(i);
---
string name="DropIn2_"+IntegerToString(u);
 

Thank you very much Marcin. It is working well.

int xy;
string text_[],text2_[],DropIn1="text_"+IntegerToString(xy),DropIn2="text2_"+IntegerToString(xy);
int OnInit(){EventSetMillisecondTimer(500);return(INIT_SUCCEEDED);}
void OnDeinit(const int reason){for(xy=0;xy<ArrayRange(text_,0);xy++){ObjectDelete(DropIn1);ObjectDelete(DropIn2);}EventKillTimer();}
void OnTimer()
  {
  CommentDropIn("123456781012345678201234567830123456784012345678501234567860123");
  CommentDropIn2("456787012345678801234567890123456710012345671101234567120123456");
  }
void CommentDropIn(string text,string fontname="Consolas Bold",int font_s=12)
  {
   StringSplit(text,StringGetCharacter("\n",0),text_);
   for(xy=0;xy<ArrayRange(text_,0);xy++)
     {
        {ObjectCreate(string(DropIn1),OBJ_LABEL,0,0,0,0);ObjectSet(string(DropIn1),OBJPROP_XDISTANCE,font_s*0.5);}
        {ObjectSet(string(DropIn1),OBJPROP_YDISTANCE,((font_s*1.5)*xy)+(font_s*1.5));ObjectSetText(string(DropIn1),text_[xy],font_s,fontname,White);}
     }
  }
void CommentDropIn2(string text2,string fontname2="Consolas Bold",int font_s2=12)
  {
   StringSplit(text2,StringGetCharacter("\n",0),text2_);
   for(xy=0;xy<ArrayRange(text2_,0);xy++)
     {
        {ObjectCreate(string(DropIn2),OBJ_LABEL,0,0,0,0);ObjectSet(string(DropIn2),OBJPROP_XDISTANCE,font_s2*0.5+567);}
        {ObjectSet(string(DropIn2),OBJPROP_YDISTANCE,((font_s2*1.5)*xy)+(font_s2*1.5));ObjectSetText(string(DropIn2),text2_[xy],font_s2,fontname2,White);}
     }
  }
 
losdelamos #:

Thank you very much Marcin. It is working well.

Maybe it's working but you need to declare name once per iteration, not once per loop.

void CommentDropIn(string text, string fontname = "Consolas Bold", int font_s = 12)
  {
   StringSplit(text, StringGetCharacter("\n", 0), text_);
   for(int xy = 0; xy < ArrayRange(text_, 0); xy++)
     {
      string name = "DropIn1_" + IntegerToString(xy);
      ObjectCreate(name, OBJ_LABEL, 0, 0, 0, 0);
      ObjectSet(name, OBJPROP_XDISTANCE, font_s * 0.5);
      ObjectSet(name, OBJPROP_YDISTANCE, ((font_s * 1.5)*xy) + (font_s * 1.5));
      ObjectSetText(name, text_[xy], font_s, fontname, White);
     }
  }
 
Marcin Madrzak #:

Maybe it's working but you need to declare name once per iteration, not once per loop.


Ok, thank you, now I understand:)

Reason: