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

 
@Vladimir Karputov
Vladimir why when closing one panel both panels close? how to avoid this?
#include <Controls\Dialog.mqh>

CAppDialog AppWindow;
CAppDialog AppWindow2;

int OnInit()
  {
//--- create application dialogue
   if(!AppWindow.Create(0,"AppWindow",0,20,20,360,324))
      return(INIT_FAILED);
   if(!AppWindow2.Create(0,"AppWindow",0,20+400,20,360+400,324))
      return(INIT_FAILED);
//--- run application
   AppWindow.Run();
   AppWindow2.Run();
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
//--- destroy dialogue
   AppWindow.Destroy(reason);
   AppWindow2.Destroy(reason);
  }
//+------------------------------------------------------------------+
//| Expert chart event function|
//+------------------------------------------------------------------+
void OnChartEvent(const int id,         // event ID 
                  const long& lparam,   // event parameter of the long type
                  const double& dparam, // event parameter of the double type
                  const string& sparam) // event parameter of the string type
  {
   AppWindow.ChartEvent(id,lparam,dparam,sparam);
   AppWindow2.ChartEvent(id,lparam,dparam,sparam);
  }
//+------------------------------------------------------------------+
Vladimir Karputov
Vladimir Karputov
  • www.mql5.com
Люди. Граждане! Огромная просьба - заполняйте свой профиль на сайте и пользуйтесь стандартными программами - устанавливайте Skype. У Skype есть очень полезная функция - показ рабочего стола. В таком случае можно оперативно подсказать по возникшей проблеме. Помните - время - деньги! Древняя народная мудрость гласит: если хочешь помочь...
 
Ruslan Khasanov:
Set different names for each window - AppWindow and AppWindow1 etc.

they already have different names

screen

Changing the string

if(!AppWindow2.Create(0,"AppWindow2",0,20+400,20,360+400,324))

doesn't do anything.
Or do you mean something else?

 
Yes indeed, mistaken...
 
peterlogin:
*** how to avoid this?

One advisor - one panel.

 
How to make a panel be on top of objects created later than the panel itself?

For example on top of a line:
example
 
peterlogin:
How to make a panel be on top of objects created later than the panel itself?

For example, over a line:

Don't create graphical objects after the panel is created.

Or collapse/expand the panel.
Документация по MQL5: Графические объекты / ObjectCreate
Документация по MQL5: Графические объекты / ObjectCreate
  • www.mql5.com
[in]  Номер подокна графика. 0 означает главное окно графика. Указанное подокно должно существовать, в противном случае функция возвращает false. Возвращает true при успешной постановке команды в очередь указанного графика, иначе false. Если объект был уже создан ранее, то производится попытка изменить его координаты. При вызове ObjectCreate...
 
Comments not related to this topic have been moved to"Questions from MQL5 MT5 MetaTrader 5 Beginners".
 

Hey Guys, 

question from a self learner!

When we create panels with the library how do we put the panel in a corner that is different form the topleft?

I fiddled with OBJ_PROP_Corner but I think there is a better way by using Panel.Align and Panel.Alignment. I played around but as a non programmer I don't know what parameters to pass and how to pass them. For example the Panel.Alignment(CRect &rect) what do those Rect things mean?

Any light much appreciated


cheers

Diego

 
Diego :

Hey Guys, 

question from a self learner!

When we create panels with the library how do we put the panel in a corner that is different form the topleft?

I fiddled with OBJ_PROP_Corner but I think there is a better way by using Panel.Align and Panel.Alignment. I played around but as a non programmer I don't know what parameters to pass and how to pass them. For example the Panel.Alignment(CRect &rect) what do those Rect things mean?

Any light much appreciated


cheers

Diego

At the time of creating the panel, we indicate the coordinates. Example for the file AppWindowEditDefine.mq5

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   
***
//--- create application dialog
   if(!ExtDialog.Create(0,"AppWindow Edit Define",0,40,40,380,344))
      return(INIT_FAILED);
//--- run application
 

I noticed that often times the *.Destroy() function simply doesn't work. It leaves objects on the chart after the Expert Deinit() function is called, especially when rapidly changing timeframes.

A simple workaround is to use pointers, instead of directly creating, modifying, and destroying the CAppDialog object.

CAppDialog AppWindow;		//Declare CAppDialog object

AppWindow.Destroy(...);		//Destroy Window object(s)

The above functions now become this:

CAppDialog *AppWindow;		//Declare CAppDialog pointer
AppWindow = new CAppDialog();	//Create new CAppDialog object at ptr address

AppWindow.Destroy(...);		//Destroy Window object(s)
delete AppWindow;		//Set the "delete" flag for objects at the ptr address (in case *.Destroy() fails)
AppWindow = NULL;		//Set the ptr address to NULL

After building my custom window class, I also create and destroy all Buttons, Panels, and other objects like this. Works like a charm!


*Note: Setting the delete flag and pointer to NULL might be overkill, but I have not had left-over objects since implementing.

Documentation on MQL5: Checkup / Point
Documentation on MQL5: Checkup / Point
  • www.mql5.com
Checkup / Point - Reference on algorithmic/automated trading language for MetaTrader 5