Having an issue with creating a dialog message box using CDialog

 

Hi everyone, I'm new to using Panels, although I have made one program.

For my next project, I wanted to make a dialog box, however, I'm running into an issue: clicking on the client area is causing CDialog's OnButtonClose() event to fire off, thus, hiding the visibility of the dialog box.

Clicking on the client area causes CDialog's OnButtonClose() event to fire off

What I've done:

  1. Create a new Indicator
  2. Create a new class ("LearnDialog") based off of CDialog (I used CDialog because I didn't need the MinMax button of CAppDIalog)
  3. Added standard code in the indicator for running a panel
  4. Override CDialog's Create method (although no custom code has been added to it)

Code:

#include "\\Lab\\LearnDialog.mqh"

//--- Global Variable
LearnDialog MyMessage;
int OnInit() {
   int middleX = (int) (ChartGetInteger(NULL,CHART_WIDTH_IN_PIXELS) / 2);
   int middleY = (int) (ChartGetInteger(NULL,CHART_HEIGHT_IN_PIXELS) / 2);
   
   MyMessage.Create(
      0,
      "MyMessage",
      0,
      middleX-160,
      middleY-90,
      middleX+160,
      middleY+90
   );
}
void OnDeinit(const int reason) {
   MyMessage.Destroy(reason);
}
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam) {
   //--- For Dialog
   MyMessage.OnEvent(id,lparam,dparam,sparam);
}
#include <Controls/Dialog.mqh>
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class LearnDialog : public CDialog {

private:
   
public:
                     LearnDialog();
                    ~LearnDialog();
   //--- create
   virtual bool      Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);
   //--- event handler
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
};

//+------------------------------------------------------------------+
//| Event Handling                                                   |
//+------------------------------------------------------------------+
EVENT_MAP_BEGIN(LearnDialog)
EVENT_MAP_END(CDialog)
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
LearnDialog::LearnDialog()
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
LearnDialog::~LearnDialog()
  {
  }
//+------------------------------------------------------------------+

bool LearnDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2) {
   if (!CDialog::Create(chart,name,subwin,x1,y1,x2,y2))
      return false;
   return true;
}
Reason: