You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello.
So.
a pointer variable to a future new, dynamically created object of the class is declared and immediately initialised with NULL value.
A simple instance of a class is declared as follows:
But in this case you cannot declare and create an instance in this way - the class has no constructor without formal parameters.
So, when declaring an instance in this way, it is necessary to specify all necessary parameters of the class object, which must be passed to the class constructor:
------------------------
In the example of working with the class, first an empty pointer to the future object is created in the indicator, and then, in OnInit(), the panel object is created, where the pointer to the created object is written to the pointer variable:
Then in OnDeinit() the object is deleted in memory by this pointer:
If you were to simply create a new object via the new operator without writing a pointer to the created object into a variable, you would not be able to delete it later, resulting in a memory leak.
So, in brief, in the example in the article
If the necessary instance of the class (CDashboard dashboard) had been created immediately, no pointers to it would have been needed - it would have been accessed in the same way using the "point" operator. And there would be no need to delete it when the work was finished - the terminal subsystem does it by itself. But it would be the only instance of the class in the programme.
Dynamic creation allows you to create new objects of the required class on the fly and refer to them by pointer. That's why dynamic creation of a class object was used in the example. Simplified, without covering some points.
Thanks for the comprehensive answer! so for each object its own constructor in another case object with requested arguments from the class, at any stage you can create different objects!(Nus becomes a little clearer).
Actually interest to create an info panel, it is a consequence of the DPI monitor, in my case 168. Comment(); is very small!
There is TerminalInfoInteger(TERMINAL_SCREEN_DPI) I want to create taking into account the resolution ... and I want to create by colour group, for convenience.
Maybe you have such a solution? Your code is good, readable... I, on the other hand, long, incomprehensible, as a result I have to rewrite everything several times! Thank you for your support!
Thank you For a comprehensive answer! so for each object has its own constructor in the other case object with requested arguments from the class, at any stage you can create different objects!(Nous becomes a little clearer).
Actually interest to create an info panel, it is a consequence of the DPI monitor, in my case 168. Comment(); is very small!
There is TerminalInfoInteger(TERMINAL_SCREEN_DPI) I want to create taking into account the resolution ... and I want to create by colour group, for convenience.
Maybe you have such a solution? Your code is good, readable... I, on the other hand, long, incomprehensible, as a result I have to rewrite everything several times! Thank you for your support!
The solution is right in the examples in the help:
Forum on trading, automated trading systems and testing trading strategies.
Gallery of UIs written in MQL
Artyom Trishkin, 2024.05.31 10:33 AM
Here(TERMINAL_SCREEN_DPI):
Example of scaling factor calculation:
When used in this way, a graphic resource will have the same size by eye on monitors with different resolutions. At the same time, the sizes of control elements (buttons, dialogue windows, etc.) will correspond to the personalisation settings.
Unfortunately, I don't have a 4K monitor, so I can't check, and for the same reason I don't enter such recalculation into the library yet - it's not serious to do at random, without checking.
Unfortunately, I don't have a 4K monitor, so I can't check, and for the same reason I don't enter such recalculation into the library yet - it's not serious to do it at random, without checking.
Artem hi! Here is the construction taking into account dpi.... But in fact you can go another way. Let's say you set the size of the header, calculate the panel size, line height and text height based on the size of the header. You specify two parameters... and whatever the dpi is. or is there a problem with that? I'm not quite sure, What's your opinion on this solution?
Artem hi! Here's a dpi based build..... But basically you can go another way. Say you set the size of the header, calculate the size of the panel line height and text height based on the size of the header. You specify two parameters... and whatever the dpi is. or is there a problem with that? I'm not quite sure, What's your opinion on this solution?
Good idea about the panel. But I noticed that the panel spontaneously drops to the bottom of the chart when switching to it from another chart. Example:
Good idea about the panel. But I noticed that the panel spontaneously drops to the bottom of the chart when switching to it from another chart. Example:
Hmm. Interesting phenomenon. I'll have to look into it in my spare time. Most likely the reason is resizing of the inactive chart.