Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 181

 
Please tell me if you can tell the width of the Label in pixels? the length of the text does not allow the letters to be of different widths
 
Money_Maker:
tell me please, can you find out the width of the Label in pixels? the length of the text does not work letters have different widths

Maybe... We have to figure it out here.

  • Width/Height- objects have width and height. If "read-only" is specified, it means that the width and height values are only calculated after the object is drawn on the chart;


and then

OBJPROP_XSIZE

Width of an object along X axis in pixels. Specified for OBJ_LABEL (read-only), OBJ_BUTTON, OBJ_BITMAP, OBJ_BITMAP_LABEL, OBJ_EDIT, OBJ_RECTANGLE_LABEL.

int

OBJPROP_YSIZE

Height of an object along the Y axis in pixels. Specified for OBJ_LABEL (read-only), OBJ_BUTTON, OBJ_BITMAP, OBJ_BITMAP_LABEL, OBJ_EDIT, OBJ_RECTANGLE_LABEL.

int

Способы привязки объектов - Константы объектов - Стандартные константы, перечисления и структуры - Справочник MQL4
Способы привязки объектов - Константы объектов - Стандартные константы, перечисления и структуры - Справочник MQL4
  • docs.mql4.com
Способы привязки объектов - Константы объектов - Стандартные константы, перечисления и структуры - Справочник MQL4
 
Alexey Viktorov:
Maybe... We'll have to sort it out here.

it turned out to be easier than planned) ObjectGetInteger(0, "name",OBJPROP_YSIZE)

Thanks)
 
string Label_name[2] = 
{ 
"jnfvin", 
"12358"
};

Another question in the global scope I declare and initialise such arrays, is it possible to do this in a separate function but for it to be visible in another function, I know that you can't return an array from a function, is there any other way...?

 
Money_Maker:

Another question in the global scope I declare and initialize such arrays, can it be done in a separate function, but that it would be visible in another function, I know that the array cannot be returned from the function, maybe there is another way...?

You can pass an array by reference into a function. Then all changes in the function will be made with the array reference to which was passed.

void OnTick()
 {
  string Label_name[2] = 
  {
   "jnfvin",
   "12358"
  };
   f1(Label_name);
    Print(Label_name[0], "  ", Label_name[1]);
 }

void f1(string & l[])
 {
  l[0] = "Новая строка";
   l[1] = "85321";
 }
 
Alexey Viktorov:

You can pass an array by reference to a function. Then all changes in the function will be made with the array referred to.


Not quite like that, the other way around would be(
Ideally get an array from a function, or declare and initialize it there, but that it would be globally visible, or a pointer to an array...
think in this direction so as not to load OnInit
 
Money_Maker:

not really, the other way around would be(
Ideally get an array from a function or declare and initialize it there, but that it would be globally visible, or a pointer to an array...
I think in this direction so as not to load OnInit
But why such a perversion?
 
Money_Maker: from a function to get an array or declare and initialize it there, but to make it globally visible, or a pointer to an array...
I'm thinking in this direction to avoid loading OnInit
You declare a global array without specifying the size. Your function sets its size with ArrayResize. And it's visible globally, and OnInit is released...
 
Artyom Trishkin:
Since the object is no longer needed, why would it be ordered in the list of objects? Delete it, and the list of required objects will remain as ordered.

Are there any examples of how to do this?
 
Evgenii:

Are there any examples of how to do this?
And you haven't shown a single piece of your code - it's not clear why you should show an example.