Panel doubling problem

 
Hello developers.
When I create a panel in MT4 using "CAppDialog" and when I save a template while the dialog box is active and then I load the same template in a new chart the dialog box becomes double and not working the way it should work. Please help me fix this problem.
 
Fatemeh Ameri:
Hello developers.
When I create a panel in MT4 using "CAppDialog" and when I save a template while the dialog box is active and then I load the same template in a new chart the dialog box becomes double and not working the way it should work. Please help me fix this problem.

When you save it to a template, the object's information is also saved and when you apply the template to a chart, the plate will be reproduced, and yet another plate will be created when the program is run.

You can modify the program so that it does not create a new plate, but it is a bit tricky.

To make things easier, you can manually delete the object information stored in the template.

<window>
height=233
fixed_height=0
<indicator>
name=main
<object>    <----------- delete from <object>
type=28
object_name=06463Border
period_flags=0
:
:
:
x_distance=29
y_distance=334
</object>    <----------- to </object>
</indicator>
 
Nagisa Unada #:

When you save it to a template, the object's information is also saved and when you apply the template to a chart, the plate will be reproduced, and yet another plate will be created when the program is run.

You can modify the program so that it does not create a new plate, but it is a bit tricky.

To make things easier, you can manually delete the object information stored in the template.

I create and sell this kind of panel, so I need to make it right programmatically. Please let me know what is the tricky way of modifying the program so that it does not create a new plate.
I think if we can find out whether any template is loaded or not we can do it but how can find out that?
I can find out nothing from your code.
 
Fatemeh Ameri #:
I create and sell this kind of panel, so I need to make it right programmatically. Please let me know what is the tricky way of modifying the program so that it does not create a new plate.
I think if we can find out whether any template is loaded or not we can do it but how can find out that?
I can find out nothing from your code.

I checked again and it was surprisingly easy.

(1) Check the object name of the panel when registering the template.

(2) Use "OnInit()" to check if the above object exists.

(3) If so, delete it.

This is all you need to do.

Since you are the seller, this level of modification should be easy for you.

 
Nagisa Unada #:

I checked again and it was surprisingly easy.

(1) Check the object name of the panel when registering the template.

(2) Use "OnInit()" to check if the above object exists.

(3) If so, delete it.

This is all you need to do.

Since you are the seller, this level of modification should be easy for you.

Thank you thousands time, I ll test this solution.

 

Hello coders;  

i want create panel for mt4 platform;

please help me in this expert code ....when i push buy button Dialog1 window hide and another push show but why when i push sell Button Dialog2 window does not hide or show?

//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#include <Controls/Dialog.mqh>
#include <Controls/Button.mqh>

CAppDialog MyInterface;
CDialog Dialog1;
CDialog Dialog2;
CButton Button1;
CButton Button2;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   MyInterface.Create(0,"MyInterface",0,20,25,500,300);
   Button1.Create(0,"Buy",0,50,20,120,80);
   Button2.Create(0,"Sell",0,350,80,420,20);
   Button1.Text("Buy");
   Button2.Text("Sell");
   MyInterface.Add(Button1);
   MyInterface.Add(Button2);
   Dialog1.Create(0,"Dialog1",0,155,0,250,100);
   Dialog2.Create(0,"Dialog2",0,255,0,350,100);
   MyInterface.Add(Dialog1);
   MyInterface.Add(Dialog2);
   MyInterface.Run();
//---
 
   return(INIT_SUCCEEDED);
   
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   MyInterface.Destroy(reason);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   MyInterface.OnEvent(id,lparam,dparam,sparam);
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="Buy")
     {
      if(Dialog1.IsVisible()==true)
      Dialog1.Hide();
      else
      Dialog1.Show();
    
     }
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="Sell")
     {
       if(Dialog2.IsVisible()==true)
      Dialog2.Hide();
      else
      Dialog2.Show();
     
     }
  }
//+------------------------------------------------------------------+
 
Fatemeh Ameri:
Hello developers.
When I create a panel in MT4 using "CAppDialog" and when I save a template while the dialog box is active and then I load the same template in a new chart the dialog box becomes double and not working the way it should work. Please help me fix this problem.

Hi mates, I know this topic is old but I am hitting the same issue . @ Nagisa Unada second solution (Find and delete objects in OnInit ) didn't work for me. The only way I can do is manually edit the template file , just like  Nagisa Unada first solution. But it is not the good solution if I send the EA to someone else, or update the template . 

So please help if there is any better work around.

Thanks.

Nagisa Unada
Nagisa Unada
  • 2021.02.04
  • www.mql5.com
Trader's profile
Reason: