combobox problem struct member undefined

 

dear every one

I'm trying to make a combobox the Event is not working.

what's wrong with my code.

the code with yellow background is wrong with message "struct member undefined";

how can I get the selected index from a combobox?

//+------------------------------------------------------------------+
//|                                                 ComboBoxTest.mq4 |
//|                                                    Kovs Attila |
//+------------------------------------------------------------------+
#property copyright "Kovs Attila"
#property version   "1.00"
#property strict
#property indicator_chart_window

#include <Controls\Dialog.mqh>
#include <Controls\ComboBox.mqh>
#include <Controls\Label.mqh>

//--- predefined constants
#define FORM_WIDTH 200
#define FORM_HEIGHT 200
#define CONT_WIDTH 100
#define CONT_HEIGHT 20
#define BTW_CONTROLS 10

enum Elist1{alfa, beta, gamma};
enum Elist2{green, gruss, gross};
enum Elist3{man, woman};

//+------------------------------------------------------------------+
//| Dialog class                                                     |
//+------------------------------------------------------------------+
class CForm : public CAppDialog{
   private:
     CComboBox    m_Box_1;
     CComboBox    m_Box_2;
     CComboBox    m_Box_3;
     CLabel       m_Label;
     
     void         OnChangem_Box_1(void);
     void         OnChangem_Box_2(void);
     void         OnChangem_Box_3(void);

   public:
                     CForm(void);
                    ~CForm(void);
                    
      virtual bool Create(void);
      //--- chart event handler
      virtual bool OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
};

bool CForm::Create(void){
      //int FORM_WIDTH = 400;
      //int FORM_HEIGHT = 500;
      //int CONT_WIDTH = 100;
      //int CONT_HEIGHT = 20;
      //int BTW_CONTROLS = 10;

   if(!CAppDialog::Create(ChartID(),"ComboBoxTest",0,20,20,20+FORM_WIDTH,20+FORM_HEIGHT))
      return(false);
   int x = 10;
   int y = 10;
   if(!m_Box_1.Create(m_chart_id,"Combo1",m_subwin,x,y,x+CONT_WIDTH,y+CONT_HEIGHT)) return(false);
   if(!m_Box_1.ItemAdd(EnumToString(Elist1(0)),Elist1(0)))return(false);
   if(!m_Box_1.ItemAdd(EnumToString(Elist1(1)),Elist1(1)))return(false);
   if(!m_Box_1.ItemAdd(EnumToString(Elist1(2)),Elist1(2)))return(false);
   m_Box_1.Select(0);
   if(!Add(m_Box_1))return(false);

   y += (CONT_HEIGHT + BTW_CONTROLS);
   if(!m_Box_2.Create(m_chart_id,"Combo2",m_subwin,x,y,x+CONT_WIDTH,y+CONT_HEIGHT)) return(false);
   if(!m_Box_2.ItemAdd(EnumToString(Elist2(0)),Elist2(0)))return(false);
   if(!m_Box_2.ItemAdd(EnumToString(Elist2(1)),Elist2(1)))return(false);
   if(!m_Box_2.ItemAdd(EnumToString(Elist2(2)),Elist2(2)))return(false);
   m_Box_2.Select(1);
   if(!Add(m_Box_2))return(false);
   
   y += (CONT_HEIGHT + BTW_CONTROLS);
   if(!m_Box_3.Create(m_chart_id,"Combo3",m_subwin,x,y,x+CONT_WIDTH,y+CONT_HEIGHT)) return(false);
   if(!m_Box_3.ItemAdd(EnumToString(Elist3(0)),Elist3(0)))return(false);
   if(!m_Box_3.ItemAdd(EnumToString(Elist3(1)),Elist3(1)))return(false);
   m_Box_3.Select(1);
   if(!Add(m_Box_3))return(false);
   
   y += (CONT_HEIGHT + BTW_CONTROLS);
   if(!m_Label.Create(m_chart_id,"Label1",0,x,y,x+CONT_WIDTH,y+CONT_HEIGHT)) return(false);
   m_Label.Text("aaaaaaaaaaaaaaaaaaaaaaa");
   if(!Add(m_Label)) return(false);
   
   return(true);
}  
//+------------------------------------------------------------------+
//| Handling events                                                  |
//+------------------------------------------------------------------+
EVENT_MAP_BEGIN(CForm)
ON_EVENT(ON_CHANGE,m_Box_1,OnChangem_Box_1)
ON_EVENT(ON_CHANGE,m_Box_2,OnChangem_Box_2)
ON_EVENT(ON_CHANGE,m_Box_3,OnChangem_Box_3)
EVENT_MAP_END(CAppDialog)

CForm::CForm(void){}

CForm::~CForm(void){}

void CForm::OnChangem_Box_1(void){
Alert(m_Box_1.Value);

}

void CForm::OnChangem_Box_2(void){
}

void CForm::OnChangem_Box_3(void){
}

//+------------------------------------------------------------------+
//| Global variables                                                 |
//+------------------------------------------------------------------+
CForm ExtDialog;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   if(!ExtDialog.Create()) return(INIT_FAILED);
//--- run application
   ExtDialog.Run();
//---
   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);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   ExtDialog.ChartEvent(id,lparam,dparam,sparam);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy dialog
   ExtDialog.Destroy(reason);
  }

 
Ma Yuliang:

dear every one

I'm trying to make a combobox the Event is not working.

what's wrong with my code.

the code with yellow background is wrong with message "struct member undefined";

how can I get the selected index from a combobox?


Alert(m_Box_1.Value());