saving the x/y position (location) of a CAppDialog panel after moving it on the chart

 

Hi everyone,


I'm starting to learn more about GUI panels using the appdialog box to add a panel to an indicator I'm writing.  I have a basic understanding of how to create a panel and various buttons and labels.  I just had one question about saving the location of the panel. 

If I move the panel on the chart and then change symbols or change time frames it resets the panel to the original location.  I know on the "OnDeinit" section it has the line to destroy the panel so I'm guessing that is why its changing it back to the original spot when it loads it back up.  I'm just curious if there is a way to save the location if you move the panel so you don't have to move it every time you change something.

Any advice would be greatly appreciated.  Here is the code I created for a basic panel just to test stuff out.

   #include <Controls/Dialog.mqh>
   #include <Controls/Button.mqh>

   CAppDialog mainInterface;
   CEdit min_15,hour_1,hour_4,daily_1;


   int OnInit()
        {

                mainInterface.Create(0,"TestPanel",0,100,150,292,350);  //main panel

                min_15.Create(0,"15 Minute",0,5,25,45,65); //15 minute button
                min_15.Text("15");
                min_15.Color(clrWhite);
                min_15.ColorBackground(clrBlack);
                min_15.ColorBorder(clrBlack);
                min_15.FontSize(20);
                min_15.TextAlign(ALIGN_CENTER);
                min_15.ReadOnly(true);
                mainInterface.Add(min_15);
        
   
                hour_1.Create(0,"Hour 1",0,50,25,90,65);  //hour 1 button
                hour_1.Text("H1");
                hour_1.Color(clrWhite);
                hour_1.ColorBackground(clrBlack);
                hour_1.ColorBorder(clrBlack);
                hour_1.FontSize(20);
                hour_1.TextAlign(ALIGN_CENTER);
                hour_1.ReadOnly(true);
                mainInterface.Add(hour_1);
   
                hour_4.Create(0,"Hour 4",0,95,25,135,65);  //hour 4 button
                hour_4.Text("H4");
                hour_4.Color(clrWhite);
                hour_4.ColorBackground(clrBlack);
                hour_4.ColorBorder(clrBlack);
                hour_4.FontSize(20);
                hour_4.TextAlign(ALIGN_CENTER);
                hour_4.ReadOnly(true);
                mainInterface.Add(hour_4);
   
                daily_1.Create(0,"Daily",0,140,25,180,65);  //daily button
                daily_1.Text("D1");
                daily_1.Color(clrWhite);
                daily_1.ColorBackground(clrBlack);
                daily_1.ColorBorder(clrBlack);
                daily_1.FontSize(20);
                daily_1.TextAlign(ALIGN_CENTER);
                daily_1.ReadOnly(true);
                mainInterface.Add(daily_1);

        }
   
   void OnDeinit(const int reason)
        {
                mainInterface.Destroy(reason);
        }

   void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
        {
                mainInterface.OnEvent(id,lparam,dparam,sparam);

                if(id == CHARTEVENT_OBJECT_CLICK && sparam == "15 Minute")
                        ChartSetSymbolPeriod(0,NULL,PERIOD_M15);
                if(id == CHARTEVENT_OBJECT_CLICK && sparam == "Hour 1")
                        ChartSetSymbolPeriod(0,NULL,PERIOD_H1);
                if(id == CHARTEVENT_OBJECT_CLICK && sparam == "Hour 4")
                        ChartSetSymbolPeriod(0,NULL,PERIOD_H4);
                if(id == CHARTEVENT_OBJECT_CLICK && sparam == "Daily")
                        ChartSetSymbolPeriod(0,NULL,PERIOD_D1);
        }

Cheers, and thank you in advance.

 

Still trying to figure out how to save any settings changes when it comes to the dialog box.  Just thought I would give it one last shot to see if anyone could help me.  No worries if no replies.  Appreciate anyone taking the time to even scan over this.

Again, Cheers and thank you in advance.

 

Hello, I am using mainInterface.Height(YourValue); and mainInterface.Move(YourXPos,YourYPos); to change the postion of the Interface. Unfortunately I do have got another problem. Even if i resized the window by setting Buttom, Top, Left and Right, it remembers the original first size and resizes back to them when it's agian maximized. So maybe you we could find a solution together or somebody else knows about that.


Best regards, and have nice Christmas

 
ctrading:

Hi everyone,


I'm starting to learn more about GUI panels using the appdialog box to add a panel to an indicator I'm writing.  I have a basic understanding of how to create a panel and various buttons and labels.  I just had one question about saving the location of the panel. 

If I move the panel on the chart and then change symbols or change time frames it resets the panel to the original location.  I know on the "OnDeinit" section it has the line to destroy the panel so I'm guessing that is why its changing it back to the original spot when it loads it back up.  I'm just curious if there is a way to save the location if you move the panel so you don't have to move it every time you change something.

Any advice would be greatly appreciated.  Here is the code I created for a basic panel just to test stuff out.

Cheers, and thank you in advance.

Panels are ****, place it in an indicator window, this dont affect the chart


 
mainInterface.Create(0,"TestPanel",0,100,150,292,350);  //main panel

mainInterface.Run();

I think you miss: mainInterface.Run(), I test it, it run ok