How to change the coordinate anchor point for the Dialog window?

 
Have a nice day. I use a Dialog (Panel) object derived from the CAppDialog class, whose position on the chart is measured by default from the top and left side of the chart. I am trying to change the "anchor point" (left, top) so that its position is measured from the top and RIGHT side of the graph.
I've looked through all the classes that CAppDialog derives from and the only thing I've found is the Alignment() function in the CWnd class. But with that I am only able to right-align various elements inside the given panel, but not the main window of the panel itself. I don't know what to do.

I need the entire dialog box to be measured from the right side of the graph. Please help.

I am attaching the code. thanks very much


#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#include <Controls/Dialog.mqh>

 CAppDialog   Panel;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

   Panel.Create(0,"Panel",0,0,0,300,300);

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
   Panel.Destroy(WRONG_VALUE);
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---

  // Panel.ChartEvent(id,lparam,dparam,sparam);
   
  }
//+------------------------------------------------------------------+

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Methods of Object Binding
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Methods of Object Binding
  • www.mql5.com
Methods of Object Binding - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

One solution to make it anchor to the right is:

replacing x==> chart_width-x

 
//+------------------------------------------------------------------+
//|                                                       AGT_EA.mq5 |
//|                                                   Ottoman_Empire |
//|                                     https://www.otto-trading.com |
//+------------------------------------------------------------------+
#property copyright "Ottoman_Empire"
#property link      "https://www.otto-trading.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Defines                                                          |
//+------------------------------------------------------------------+
#define bgFix (C'0xF7,0xF7,0xF7')

//+------------------------------------------------------------------+
//| Include App Classes                                              |
//+------------------------------------------------------------------+
#include <Controls\Dialog.mqh>
#include <Controls\Button.mqh>
#include <Controls\RadioGroup.mqh>
#include <Controls\Label.mqh>
#include <Controls\Edit.mqh>
#include <Controls\CheckBox.mqh>
#include <Controls\ComboBox.mqh>
#include <SpinEditDouble.mqh>

CAppDialog loginPanel;


CButton loginButton1;
CEdit loginInputBox;
CLabel loginText1;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit(){
   if(!loginApp()){
      return(INIT_FAILED); 
   }
//--- run application
loginPanel.Run();
   
//--- succeed
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason){
//--- destroy dialog
   loginPanel.Destroy(reason);
}

//+------------------------------------------------------------------+
//| Login App                                                        |
//+------------------------------------------------------------------+
bool loginApp(){
   long m_chart_id = ChartID();
   long heightScreen=ChartGetInteger(m_chart_id,CHART_HEIGHT_IN_PIXELS,0);
   long widthScreen=ChartGetInteger(m_chart_id,CHART_WIDTH_IN_PIXELS,0);
   int height = 130;//Panel Height
   int width =  200;//Panel Width
   
   //Standart place
   int x1 =3;
   int y1 =82;
   int x2 = x1+width;
   int y2 = y1+height;

   int dialogPlace = 5;//Here is placing code
   
  
   if(dialogPlace ==5){//Center
      x1 = int(widthScreen/2 - (width/2));
      y1 = int(heightScreen/2 - (height/2));
      x2 = x1+width;
      y2 = y1+height;
   }else if(dialogPlace ==4){//Right Down
      x1 = int(widthScreen-width);
      y1 = int(heightScreen-height);
      x2 = x1+width;
      y2 = y1+height;
   }else if(dialogPlace ==3){//Right Top
      x1 = int(widthScreen-width);
      y1 = 0;
      x2 = x1+width;
      y2 = y1+height;
   }else if(dialogPlace ==2){//Left Down
      x1 = 0;
      y1 = int(heightScreen-height);
      x2 = x1+width;
      y2 = y1+height;
   }else if(dialogPlace ==1){//Left Top
      x1 = 0;
      y1 = 0;
      x2 = x1+width;
      y2 = y1+height;
   }
   
   
   if(!loginPanel.Create(m_chart_id,"Password",0,x1,y1,x2,y2)){
      return(false);
   }
   //Login Text 1
   if(!loginText1.Create(m_chart_id,"loginText1",0,5,10,0,0))
      return(false);   
   if(!loginText1.Text("Password:"))
      return(false);
   if(!loginText1.Color(clrGray))
      return(false);
   if(!loginText1.Font("Calibri"))
      return(false);
   if(!loginText1.FontSize(10))
      return(false);
   if(!loginPanel.Add(loginText1))
      return(false);    
   
   //Login Input Box
   if(!loginInputBox.Create(m_chart_id,"loginInputBox",0,65,6,187,27))
      return(false);
   if(!loginInputBox.Color(clrGray))
      return(false);
   if(!loginPanel.Add(loginInputBox))
      return(false);
   
   //Login Button 1
   if(!loginButton1.Create(m_chart_id,"loginButton1",0,5,60,187,95))
      return(false);
   if(!loginButton1.Text("Login"))
      return(false);
   if(!loginButton1.Font("Calibri Bold"))
      return(false);
   if(!loginButton1.FontSize(12))
      return(false);
   if(!loginButton1.ColorBackground(clrAliceBlue))
      return(false);
   if(!loginPanel.Add(loginButton1))
      return(false);
          
   return(true);
}
//+------------------------------------------------------------------+
//| 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
  {
      loginPanel.ChartEvent(id,lparam,dparam,sparam);

  }

You can control like this. (Edit: OnChartEvent functions added)