Problem with hiding button in panel in Cpanel dialog mql4

Problem with hiding button in panel in Cpanel dialog mql4

Manage alerts

Loading saved threads...

user2647394 · External communityPost link
External question — Stack Overflow Stack Exchange Author: user2647394 Original post: https://stackoverflow.com/questions/73338549 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I made this simple panel as below it have one label and two button when I press one of them the other will be hidden but when i click at place of hidden button it still work I don't know why I used "cPanel" Dialog from include library and button(in Control Folder) I used .Hide() command but it still actionable also tried the .Disable and Deactivate features but not working at all code from mqh file: #define INDENT_LEFT_ScrollQ (11) // indent from left (with allowance for border width)(for Scroll Bar Only) #define INDENT_LEFTQ (11) // indent from left (with allowance for border width) #define INDENT_TOPQ (11) // indent from top (with allowance for border width) #define INDENT_RIGHTQ (11) // indent from right (with allowance for border width) #define INDENT_BOTTOMQ (11) // indent from bottom (with allowance for border width) #define CONTROLS_GAP_XQ (80) // gap by X coordinate #define CONTROLS_GAP_YQ (40) // gap by Y coordinate //--- for buttons #define BUTTON_WIDTHQ (60) // size by X coordinate #define BUTTON_HEIGHTQ (20) // size by Y coordinate //--- for the indication area #define EDIT_HEIGHTQ (20) // size by Y coordinate #define GROUP_WIDTHQ (150) // size by X coordinate #define LIST_HEIGHTQ (379) // size by Y coordinate #define RADIO_HEIGHTQ (56) // size by Y coordinate #define CHECK_HEIGHTQ (93) // size by Y coordinate //+------------------------------------------------------------------+ //| Class CPanelDialog | //| Usage: main dialog of the SimplePanel application | //+------------------------------------------------------------------+ class CPanelDialogQ : public CAppDialog { private: CLabel m_Label_Q_text; CButton m_button_Yes; CButton m_button_No; //**************************************************** public: CPanelDialogQ(void); ~CPanelDialogQ(void); //--- create virtual bool CreateQ(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2,string QText); //--- chart event handler virtual bool OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam); protected: //--- create dependent controls bool CreateLabel_Q_text(string QT); bool CreateButton_Yes(void); bool CreateButton_No(void); void OnClick_button_Yes(void); void OnClick_button_No(void); }; //+------------------------------------------------------------------+ //| Event Handling | //+------------------------------------------------------------------+ EVENT_MAP_BEGIN(CPanelDialogQ) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ ON_EVENT(ON_CLICK,m_button_Yes,OnClick_button_Yes) ON_EVENT(ON_CLICK,m_button_No,OnClick_button_No) EVENT_MAP_END(CAppDialog) //+------------------------------------------------------------------+ //| Constructor | //+------------------------------------------------------------------+ CPanelDialogQ::CPanelDialogQ(void) { } //+------------------------------------------------------------------+ //| Destructor | //+------------------------------------------------------------------+ CPanelDialogQ::~CPanelDialogQ(void) { } //+------------------------------------------------------------------+ //| Create | //+------------------------------------------------------------------+ bool CPanelDialogQ::CreateQ(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2,string QText) { if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2)) return(false); //--- create dependent controls if(!CreateLabel_Q_text( QText)) return(false); if(!CreateButton_Yes()) return(false); if(!CreateButton_No()) return(false); //--- succeed return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ bool CPanelDialogQ::CreateLabel_Q_text(string QT) { //--- coordinates int x1=INDENT_LEFTQ; int y1=INDENT_TOPQ; int x2=ClientAreaWidth()-(INDENT_RIGHTQ+BUTTON_WIDTHQ+CONTROLS_GAP_XQ); int y2=y1+EDIT_HEIGHTQ; //--- create if(!m_Label_Q_text.Create(m_chart_id,"QT",m_subwin,x1,y1,x2,y2)) return(false); if(!m_Label_Q_text.Text(QT)) return(false); if(!m_Label_Q_text.FontSize(12)) return(false); if(!m_Label_Q_text.Color(clrBlack)) return(false); if(!m_Label_Q_text.ColorBorder(clrBlack)) return(false); if(!m_Label_Q_text.ColorBackground(clrBlack)) return(false); // if(!m_edit.ReadOnly(true)) // return(false); if(!Add(m_Label_Q_text)) return(false); m_Label_Q_text.Alignment(WND_ALIGN_WIDTH,INDENT_LEFTQ,0,INDENT_RIGHTQ+BUTTON_WIDTHQ+CONTROLS_GAP_XQ,0); //--- succeed return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ bool CPanelDialogQ::CreateButton_Yes(void) { //--- coordinates int x1=INDENT_LEFTQ; int y1=INDENT_TOPQ+CONTROLS_GAP_YQ; int x2=x1+BUTTON_WIDTHQ; int y2=y1+BUTTON_HEIGHTQ; //--- create if(!m_button_Yes.Create(m_chart_id,m_name+"Yes",m_subwin,x1,y1,x2,y2)) return(false); if(!m_button_Yes.Text("Yes")) return(false); if(!Add(m_button_Yes)) return(false); m_button_Yes.Alignment(WND_ALIGN_RIGHT,0,0,INDENT_RIGHTQ+CONTROLS_GAP_XQ*2,0); //--- succeed return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ bool CPanelDialogQ::CreateButton_No(void) { //--- coordinates int x1=INDENT_LEFTQ+CONTROLS_GAP_XQ; int y1=INDENT_TOPQ+CONTROLS_GAP_YQ; int x2=x1+BUTTON_WIDTHQ; int y2=y1+BUTTON_HEIGHTQ; //--- create if(!m_button_No.Create(m_chart_id,m_name+"NO",m_subwin,x1,y1,x2,y2)) return(false); if(!m_button_No.Text("NO")) return(false); if(!Add(m_button_No)) return(false); m_button_No.Alignment(WND_ALIGN_RIGHT,0,0,INDENT_RIGHTQ+CONTROLS_GAP_XQ*1,0); //--- succeed return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void CPanelDialogQ::OnClick_button_Yes(void) { Print("OnClick_button_Yes", "Last Error: ",GetLastError()); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void CPanelDialogQ::OnClick_button_No(void) { Print("OnClick_button_No", "Last Error: ",GetLastError()); m_button_Yes.Hide(); } //+------------------------------------------------------------------+ and the indicator code: //+------------------------------------------------------------------+ //| Indicator_Q_Test.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window #include <WinUser32.mqh> #include "PanelDialog_Q.mqh" CPanelDialogQ ExtDialog; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping if(!ExtDialog.CreateQ(0,"Question",0,100,100,400,230,"This the test Question?")) return(INIT_FAILED); //--- run application if(!ExtDialog.Run()) return(INIT_FAILED); // int k=0; // k=MessageBoxW(WindowHandle(Symbol(),Period()),"Are you sure to Disable Total ?","Question",MB_YESNO|MB_ICONQUESTION|MB_TOPMOST); // Print("k: ",k); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| 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); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- ExtDialog.ChartEvent(id,lparam,dparam,sparam); } //+------------------------------------------------------------------+
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: user2647394 Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/73338549 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I made this simple panel as below it have one label and two button when I press one of them the other will be hidden but when i click at place of hidden button it still work I don't know why I used "cPanel" Dialog from include library and button(in Control Folder) I used .Hide() command but it still actionable also tried the .Disable and Deactivate features but not working at all code from mqh file: #define INDENT_LEFT_ScrollQ (11) // indent from left (with allowance for border width)(for Scroll Bar Only) #define INDENT_LEFTQ (11) // indent from left (with allowance for border width) #define INDENT_TOPQ (11) // indent from top (with allowance for border width) #define INDENT_RIGHTQ (11) // indent from right (with allowance for border width) #define INDENT_BOTTOMQ (11) // indent from bottom (with allowance for border width) #define CONTROLS_GAP_XQ (80) // gap by X coordinate #define CONTROLS_GAP_YQ (40) // gap by Y coordinate //--- for buttons #define BUTTON_WIDTHQ (60) // size by X coordinate #define BUTTON_HEIGHTQ (20) // size by Y coordinate //--- for the indication area #define EDIT_HEIGHTQ (20) // size by Y coordinate #define GROUP_WIDTHQ (150) // size by X coordinate #define LIST_HEIGHTQ (379) // size by Y coordinate #define RADIO_HEIGHTQ (56) // size by Y coordinate #define CHECK_HEIGHTQ (93) // size by Y coordinate //+------------------------------------------------------------------+ //| Class CPanelDialog | //| Usage: main dialog of the SimplePanel application | //+------------------------------------------------------------------+ class CPanelDialogQ : public CAppDialog { private: CLabel m_Label_Q_text; CButton m_button_Yes; CButton m_button_No; //**************************************************** public: CPanelDialogQ(void); ~CPanelDialogQ(void); //--- create virtual bool CreateQ(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2,string QText); //--- chart event handler virtual bool OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam); protected: //--- create dependent controls bool CreateLabel_Q_text(string QT); bool CreateButton_Yes(void); bool CreateButton_No(void); void OnClick_button_Yes(void); void OnClick_button_No(void); }; //+------------------------------------------------------------------+ //| Event Handling | //+------------------------------------------------------------------+ EVENT_MAP_BEGIN(CPanelDialogQ) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ ON_EVENT(ON_CLICK,m_button_Yes,OnClick_button_Yes) ON_EVENT(ON_CLICK,m_button_No,OnClick_button_No) EVENT_MAP_END(CAppDialog) //+------------------------------------------------------------------+ //| Constructor | //+------------------------------------------------------------------+ CPanelDialogQ::CPanelDialogQ(void) { } //+------------------------------------------------------------------+ //| Destructor | //+------------------------------------------------------------------+ CPanelDialogQ::~CPanelDialogQ(void) { } //+------------------------------------------------------------------+ //| Create | //+------------------------------------------------------------------+ bool CPanelDialogQ::CreateQ(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2,string QText) { if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2)) return(false); //--- create dependent controls if(!CreateLabel_Q_text( QText)) return(false); if(!CreateButton_Yes()) return(false); if(!CreateButton_No()) return(false); //--- succeed return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ bool CPanelDialogQ::CreateLabel_Q_text(string QT) { //--- coordinates int x1=INDENT_LEFTQ; int y1=INDENT_TOPQ; int x2=ClientAreaWidth()-(INDENT_RIGHTQ+BUTTON_WIDTHQ+CONTROLS_GAP_XQ); int y2=y1+EDIT_HEIGHTQ; //--- create if(!m_Label_Q_text.Create(m_chart_id,"QT",m_subwin,x1,y1,x2,y2)) return(false); if(!m_Label_Q_text.Text(QT)) return(false); if(!m_Label_Q_text.FontSize(12)) return(false); if(!m_Label_Q_text.Color(clrBlack)) return(false); if(!m_Label_Q_text.ColorBorder(clrBlack)) return(false); if(!m_Label_Q_text.ColorBackground(clrBlack)) return(false); // if(!m_edit.ReadOnly(true)) // return(false); if(!Add(m_Label_Q_text)) return(false); m_Label_Q_text.Alignment(WND_ALIGN_WIDTH,INDENT_LEFTQ,0,INDENT_RIGHTQ+BUTTON_WIDTHQ+CONTROLS_GAP_XQ,0); //--- succeed return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ bool CPanelDialogQ::CreateButton_Yes(void) { //--- coordinates int x1=INDENT_LEFTQ; int y1=INDENT_TOPQ+CONTROLS_GAP_YQ; int x2=x1+BUTTON_WIDTHQ; int y2=y1+BUTTON_HEIGHTQ; //--- create if(!m_button_Yes.Create(m_chart_id,m_name+"Yes",m_subwin,x1,y1,x2,y2)) return(false); if(!m_button_Yes.Text("Yes")) return(false); if(!Add(m_button_Yes)) return(false); m_button_Yes.Alignment(WND_ALIGN_RIGHT,0,0,INDENT_RIGHTQ+CONTROLS_GAP_XQ*2,0); //--- succeed return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ bool CPanelDialogQ::CreateButton_No(void) { //--- coordinates int x1=INDENT_LEFTQ+CONTROLS_GAP_XQ; int y1=INDENT_TOPQ+CONTROLS_GAP_YQ; int x2=x1+BUTTON_WIDTHQ; int y2=y1+BUTTON_HEIGHTQ; //--- create if(!m_button_No.Create(m_chart_id,m_name+"NO",m_subwin,x1,y1,x2,y2)) return(false); if(!m_button_No.Text("NO")) return(false); if(!Add(m_button_No)) return(false); m_button_No.Alignment(WND_ALIGN_RIGHT,0,0,INDENT_RIGHTQ+CONTROLS_GAP_XQ*1,0); //--- succeed return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void CPanelDialogQ::OnClick_button_Yes(void) { Print("OnClick_button_Yes", "Last Error: ",GetLastError()); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void CPanelDialogQ::OnClick_button_No(void) { Print("OnClick_button_No", "Last Error: ",GetLastError()); m_button_Yes.Hide(); } //+------------------------------------------------------------------+ and the indicator code: //+------------------------------------------------------------------+ //| Indicator_Q_Test.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window #include <WinUser32.mqh> #include "PanelDialog_Q.mqh" CPanelDialogQ ExtDialog; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping if(!ExtDialog.CreateQ(0,"Question",0,100,100,400,230,"This the test Question?")) return(INIT_FAILED); //--- run application if(!ExtDialog.Run()) return(INIT_FAILED); // int k=0; // k=MessageBoxW(WindowHandle(Symbol(),Period()),"Are you sure to Disable Total ?","Question",MB_YESNO|MB_ICONQUESTION|MB_TOPMOST); // Print("k: ",k); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| 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); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- ExtDialog.ChartEvent(id,lparam,dparam,sparam); } //+------------------------------------------------------------------+

Cancel quote

Checking account access…