This is not to answer your problem, but it may interesting you.

- 2012.02.07
- MetaQuotes Software Corp.
- www.mql5.com
Actually I dont know how it works, but I edited the examples EA in MT5 named "Controls" which is in folder "Experts\Examples\Controls". I edited (deleted some lines) so we can study more about combo box. There are 2 files, one as indicator and the other as include files. Both should be put in indicator folder. The first is indicator named "Controls1.mq5" and the second named "ControlsDialog1.mqh".
"Controls1.mq5"
#include "ControlsDialog1.mqh" //+------------------------------------------------------------------+ //| Global Variables | //+------------------------------------------------------------------+ CControlsDialog ExtDialog; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create application dialog if(!ExtDialog.Create(0,"Controls",0,20,20,360,124)) return(INIT_FAILED); //--- run application ExtDialog.Run(); //--- succeed return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- destroy dialog ExtDialog.Destroy(reason); } //+------------------------------------------------------------------+ //| Expert chart event 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(rates_total); } 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 { ExtDialog.ChartEvent(id,lparam,dparam,sparam); } //+------------------------------------------------------------------+
"ControlsDialog1.mqh"
//+------------------------------------------------------------------+ //| ControlsDialog1.mqh | //| Copyright 2009-2013, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #include <Controls\Dialog.mqh> #include <Controls\ComboBox.mqh> //+------------------------------------------------------------------+ //| defines | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Class CControlsDialog | //| Usage: main dialog of the Controls application | //+------------------------------------------------------------------+ class CControlsDialog : public CAppDialog { private: // CEdit m_edit; // the display field object CComboBox m_combo_box; // the dropdown list object public: CControlsDialog(void); ~CControlsDialog(void); //--- create virtual bool Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2); //--- chart event handler // virtual bool OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam); protected: //--- create dependent controls // bool CreateEdit(void); bool CreateComboBox(void); //--- handlers of the dependent controls events void OnChangeComboBox(void); }; //+------------------------------------------------------------------+ //| Constructor | //+------------------------------------------------------------------+ CControlsDialog::CControlsDialog(void) { } //+------------------------------------------------------------------+ //| Destructor | //+------------------------------------------------------------------+ CControlsDialog::~CControlsDialog(void) { } //+------------------------------------------------------------------+ //| Create | //+------------------------------------------------------------------+ bool CControlsDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2) { if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2)) return(false); //--- create dependent controls // if(!CreateEdit()) // return(false); if(!CreateComboBox()) return(false); //--- succeed return(true); } //+------------------------------------------------------------------+ //| Create the "ComboBox" element | //+------------------------------------------------------------------+ bool CControlsDialog::CreateComboBox(void) { //--- coordinates int x1=11; int y1=11; int x2=x1+150; int y2=y1+20; //--- create if(!m_combo_box.Create(m_chart_id,m_name+"ComboBox",m_subwin,x1,y1,x2,y2)) return(false); if(!Add(m_combo_box)) return(false); //--- fill out with strings for(int i=0;i<16;i++) if(!m_combo_box.ItemAdd("Item "+IntegerToString(i))) return(false); //--- succeed return(true); }
Hope it help.
Dear all,
I created a ComboBox object in an indicator subwindow(by the code attached), But when I click the drop-down arrow next to the control, nothing was pop out. What is wrong with my code? Many thanks for your time and efforts.
Dear Belido,
Thank you for your effective information! I followed the link In your reply and add the CreateComboBox() function as a member function of the CPanelDialog Class. And the ComboBox that I needed is created there. To make it clear, I have attached the source code in case someone might need it....
bool CPanelDialog::CreateComboBox(void) { int x1=100, y1=100, xsize=150, ysize=20; int x2=x1+xsize; int y2=y1+ysize; long subWinID=ChartWindowFind(); if(!m_comboBox.Create(0,"ComboBox",(int)subWinID,x1,y1,x2,y2)) return(false); if(!m_comboBox.AddItem("PL: OPPPPPPPPPPPP",0)) return(false); if(!m_comboBox.AddItem("TL: Trend Line",1)) return(false); if(!m_comboBox.AddItem("MA: Moving Average",2)) return(false); if(!m_comboBox.AddItem("RSI: RSI Indicator",3)) return(false); if(!Add(m_comboBox)) return(false); /* ATTENTION: the above call to CPanelDialog::Add(control) is definietely necessary. otherwise nothing will be popped out when the arrow of the combobox is clicked. */ //--- succeed Alert("the combobox is created ok!"); return(true); }
Hello,
i used this code in my EA, but i dont understand fully, why i have not the combobox only and also the panel around
can you explain?
amando

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear all,
I created a ComboBox object in an indicator subwindow(by the code attached), But when I click the drop-down arrow next to the control, nothing was pop out. What is wrong with my code? Many thanks for your time and efforts.