Hiding Issue with a panel

 

Hello everyone,
I have a question regarding Hiden and restoring a panel. When I hide certain objects in my panel and then minimize and restore the panel,
all the objects that are supposed to be hidden are shown again. How can I restore the panel so that the objects remain hidden?
Is there a workaround or something similar? Enclosed is the source code.

Thank you very much

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


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


#define PannelName "Hiding Issue"
#define PannelWidth 220
#define PannelHeight 200


#define ExecuteButtonName "ExecuteButton"
#define ExecuteButtonWidth 180
#define ExecuteButtonHeight 35
#define ExecuteButtonXDist 10
#define ExecuteButtonYDist 10

#define SelectButtonName "SelectButton"
#define SelectButtonWidth 180
#define SelectButtonHeight 35
#define SelectButtonXDist 10
#define SelectButtonYDist 50


CAppDialog Pannel;
CButton    TestButton,SelectButton;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
     
     Pannel.Create(0,PannelName,0, 10, 10,PannelWidth,PannelHeight);
     Pannel.Run();

     
     TestButton.Create(0,ExecuteButtonName,0,ExecuteButtonXDist,ExecuteButtonYDist,0,0);
     Pannel.Add(TestButton);     
     TestButton.Height(ExecuteButtonHeight);
     TestButton.Width(ExecuteButtonWidth);
     TestButton.Text("Hide other Button");
     TestButton.FontSize(11);
     TestButton.Locking(true);
     
     SelectButton.Create(0,SelectButtonName,0,SelectButtonXDist,SelectButtonYDist,0,0);
     Pannel.Add(SelectButton);
     SelectButton.Height(SelectButtonHeight);
     SelectButton.Width(SelectButtonWidth);
     SelectButton.Text("Button to hide");
     SelectButton.FontSize(11);
      
     
   return(INIT_SUCCEEDED);
  }
  
  void OnDeinit(const int reason)
  {
//---      
   Pannel.Destroy(1);
   //}
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   Pannel.ChartEvent(id,lparam,dparam,sparam);
   
   
   
    if(id == CHARTEVENT_OBJECT_CLICK && sparam == ExecuteButtonName )
    {
         if(TestButton.Pressed())
         {
         TestButton.Text("now minimize/restore the panel");
         TestButton.FontSize(9);
         SelectButton.Hide();
         }       
         else
           {
            TestButton.Text("Hide other Button");
            TestButton.FontSize(11);
            SelectButton.Show();
           }
   
    } 
    
    if(id == CHARTEVENT_OBJECT_CLICK && sparam == SelectButtonName )
    {

         
   
    }
   if(id == CHARTEVENT_OBJECT_CLICK && sparam == minMax )
   {

   }
   
  }
//+------------------------------------------------------------------+