Discussion of article "How to create a graphical panel of any complexity level" - page 8

 
Alexander:

Hello!

I have such a question - I would like to create several tabs on the trading panel, i.e. by pressing one button one set of items appears, by pressing another button another set of items appears. To hide elements from one tab I applied Hide() property for this element in onClick event handler of the tab button and the element is no longer visible on the panel, but it does not lose its properties and if you click on the place where this element was, then onEvent() of the panel will accept this event. Question - how to make the hidden element also did not react to any actions of the user. I tried to enable the property Element.Disable() again in the onClick method of the button tab, but nothing happens, the element as reacted to the button click so still reacts although invisible. How to switch it off programmatically by clicking on one tab and then switch it on programmatically by clicking on another tab?

Try to patch the control library: there is a line missing at the beginning of the OnMouseEvent method in the Wnd.mqh file:

if(!IS_ENABLED || !IS_VISIBLE) return false;

Details are described in the article(Application of OLAP in Trading (Part 2) - the article is about OLAP, but there is a section on GUI where the above problem is touched upon):

in the minimised state, the "resize" button is hidden and made inactive. The problem is in the CWnd::OnMouseEvent method. It lacks such a check:

  // if(!IS_ENABLED || !IS_VISIBLE) return false; - this line is not present

As a result, even disabled and invisible "controls" intercept events. Obviously, the problem could be solved by setting the appropriate Z-order of controls. However, even here we found a flaw - the library does not take into account the Z-order of elements. In particular, if you look into the CWndContainer::OnMouseEvent method, you will see a simple loop in reverse order through all subordinate elements, without trying to determine their priority by Z-order.

Thus, either another "patch" of the library or some "trick" in a derived class is required.

In principle, there is a lot that needs to be fixed in the standard control library. That's why an alternative, already patched, implementation of ControlsPlus was written - you can get it in its entirety in the article MQL as a means of marking up the graphical interface of MQL programs. Part 2 (if you are interested, there are parts 1 and 3).

Язык MQL как средство разметки графического интерфейса MQL-программ. Часть 2
Язык MQL как средство разметки графического интерфейса MQL-программ. Часть 2
  • www.mql5.com
В первой части публикации мы рассмотрели базовые принципы описания раскладки графического интерфейса MQL-программ на языке MQL. Для их реализации потребовалось создать несколько классов, отвечающих непосредственно за инициализацию интерфейсных элементов, их объединение в общую иерархию и настройку свойств. Сейчас мы готовимся перейти к более...
 
Stanislav Korotky:

Try to patch the control library: the Wnd.mqh file is missing a line at the beginning of the OnMouseEvent method:

Details are described in the article(Application of OLAP in Trading (Part 2) - the article is about OLAP, but there is a section on GUI, where the above problem is touched upon):

Basically, there are a lot of things in the standard control library that would need to be tweaked. That's why an alternative, already patched, ControlsPlus implementation was written - you can get it in its entirety in the article MQL as a means of marking up the GUI of MQL programs. Part 2 (if you are interested, there are parts 1 and 3).

Thank you, we will try it.

 

How to write/transmit text to CLabel from OnTick ?

class CControlsDialog : public CAppDialog
{
private:
CLabel m_label;// CLabel object

.....

void OnTick()
{

m_label.Text(DoubleToString(Ask,4));

....

I get an error

'm_label' - undeclared identifier ...

what is wrong?

Документация по MQL5: Стандартная библиотека / Панели и диалоги / CLabel
Документация по MQL5: Стандартная библиотека / Панели и диалоги / CLabel
  • www.mql5.com
//|                                                ControlsLabel.mq5 | //|                        Copyright 2017, MetaQuotes Software Corp. | //|                                             https://www.mql5.com | //| defines                                                          |  INDENT_LEFT                         (11)      ...
 
Renat Akhtyamov:

How to write/transmit text to CLabel from OnTick ?

I get the error

'm_label' - undeclared identifier ...

what is wrong?

Have you done binding to the chart, coordinates, etc. as in the CreateLabel() function shown here in the help?

 
Vasiliy Pushkaryov:

And the binding to the chart, coordinates, etc. as in CreateLabel() is shown here in the help, have you done it?

yes

If you write text to the object right there, everything is fine.

But if I try to write it in OnTick, it fails.

You don't have to recreate the object on every tick, do you?
 
Renat Akhtyamov:

yes

If you write text to the object right there, everything is fine.

But if I try to write it in OnTick, it fails.

You don't have to recreate the object on every tick, do you?
What if m_label is moved to the public section?
 
Vasiliy Pushkaryov:
What if m_label is moved to the public section ?

I tried that, same error.

It's just that I'm doing it on 4pc.

I think that's the problem.

Plus this one doesn't work, though it compiles.

m_scroll_v1. Disable(); (I'm trying to switch radio buttons, it's interesting to change the interface). Destroy() works, but Disable doesn't want to do it

 
Renat Akhtyamov:

tried

It's just that I'm doing it on a 4RK.

I think that's the problem.

Plus this one doesn't work, even though it compiles.

m_scroll_v1. Disable(); (I'm trying to switch radio buttons, it's interesting to change the interface). Destroy() works, but Disable doesn't want to do it

Everything works in 4. And the object you have defined. Call from it should be made. Like Panel.m_label.Text( "Max.Margin").
 
Vasiliy Pushkaryov:
Everything works in 4. And the object that you have defined. You should make a call from it. Like Panel.m_label.Text( "Max.Margin").

It works like this.

thanks!

I added the parent first, then moved it to public and it works.

and this is m_scroll_v1. Disable(); doesn't work yet

 
Renat Akhtyamov:

it works like this

thank you!

Added the parent first, then moved it to public and it works

and this m_scroll_v1. Disable(); doesn't work yet

I haven't encountered it yet. I don't know. Stanislav answers one of the questions in the 27th post of this thread, Disable of the standard library is also touched upon there, have a look.