e.bravetti:
Hi guy
I try to use class but I have big problems......follows my test code:
In the image there is the result
the dialog is create but the dialog does not move even if there is control in OnChartEvent
the button close you can not see the buttons in close
how I do to insert the close button and for example a combo box or an edit?
Please help me wiith an example
Thanks
This should get you going:
#property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "https://www.mql4.com" #property version "1.00" #property strict #property indicator_separate_window #property indicator_plots 0 #property indicator_buffers 0 #property indicator_minimum 0.0 #property indicator_maximum 0.0 //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ #include <MyAppDialog.mqh> MyAppDialog InstMyAppDialog; int OnInit() { if(!InstMyAppDialog.Create(0,"My App Dialog",0,0,0,0,300)) return(INIT_FAILED); if(!InstMyAppDialog.Run()) return(INIT_FAILED); //--- indicator buffers mapping //--- 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) { //--- InstMyAppDialog.ChartEvent(id,lparam,dparam,sparam); } //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| MyAppDialog.mqh | //| Copyright 2014, MetaQuotes Software Corp. | //| https://www.mql4.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "https://www.mql4.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include <Controls\Dialog.mqh> #include <MyWndContainer.mqh> class MyAppDialog : public CAppDialog { private: MyWndContainer InstMyWndContainer; CLabel lblMyAppLabel; bool CreateMyContainer(void); bool CreateMyAppLabel(void); public: MyAppDialog(); ~MyAppDialog(); virtual bool Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ MyAppDialog::MyAppDialog() { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ MyAppDialog::~MyAppDialog() { } //+------------------------------------------------------------------+ bool MyAppDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2) { //--- calling the method of the parent class if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2)) return(false); //--- additional controls shall be created here if(!CreateMyContainer()) return(false); if(!CreateMyAppLabel()) return(false); Run(); //--- success return(true); } bool MyAppDialog::CreateMyContainer(void) { if(!InstMyWndContainer.Create(m_chart_id,"My Container",m_subwin,0,0,0,300)) return(false); if(!Add(InstMyWndContainer)) return(false); InstMyWndContainer.Show(); return(true); } bool MyAppDialog::CreateMyAppLabel(void) { if(!lblMyAppLabel.Create(m_chart_id,"lblMyAppLabel"+m_name, m_subwin,100,5,50,102)) return(false); lblMyAppLabel.Text("MyAppLabel:"); lblMyAppLabel.FontSize(8); if(!Add(lblMyAppLabel)) return(false); return(true); }
//+------------------------------------------------------------------+ //| MyWndContainer.mqh | //| | //| https://www.mql4.com | //+------------------------------------------------------------------+ #property copyright "" #property link "https://www.mql4.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include <Controls\WndContainer.mqh> #include <Controls\Label.mqh> class MyWndContainer : public CWndContainer { private: CLabel lblMyLabel; bool CreateMyLabel(void); public: MyWndContainer(); ~MyWndContainer(); virtual bool Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ MyWndContainer::MyWndContainer() { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ MyWndContainer::~MyWndContainer() { } //+------------------------------------------------------------------+ bool MyWndContainer::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2) { if(!CWndContainer::Create(chart,name,subwin,x1,y1,x2,y2)) return(false); if(!CreateMyLabel()) return(false); return(true); } bool MyWndContainer::CreateMyLabel(void) { if(!lblMyLabel.Create(m_chart_id,"lblMyLabel"+m_name, m_subwin,10,5,50,22)) return(false); lblMyLabel.Text("MyLabel:"); lblMyLabel.FontSize(8); if(!Add(lblMyLabel)) return(false); return(true); }Hope it helps.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guy
I try to use class but I have big problems......follows my test code:
In the image there is the result
the dialog is create but the dialog does not move even if there is control in OnChartEvent
the button close you can not see the buttons in close
how I do to insert the close button and for example a combo box or an edit?
Please help me wiith an example
Thanks