ComboBox control not working in MT4?

 

Does anyone have any experience in using the ComboBox control?  

I'm trying to use the ComboBox control that is part of the standard MQL4 library. Creating it is very simple, but when I click it to open the list, it doesn't open.

I do .Create, then .AddItem a few times, and it shows fine on the chart, except that when I click it to show the list of items it doesn't do anything.

It's working fine in MT5, just not in MT4.

I have only been able to find the page below: 

https://www.mql5.com/en/docs/standardlibrary/controls/ccombobox 

Since it's included in the standard MQL4 library I can only assume that it's supposed to work?

 
kieran.w:

Does anyone have any experience in using the ComboBox control?  

I'm trying to use the ComboBox control that is part of the standard MQL4 library. Creating it is very simple, but when I click it to open the list, it doesn't open.

I do .Create, then .AddItem a few times, and it shows fine on the chart, except that when I click it to show the list of items it doesn't do anything.

It's working fine in MT5, just not in MT4.

I have only been able to find the page below: 

https://www.mql5.com/en/docs/standardlibrary/controls/ccombobox 

Since it's included in the standard MQL4 library I can only assume that it's supposed to work?

Wow 9 years later and I have the same issue :( 
Please does anyone know why this is happening? 
Is there any additional code I have to add to make the combobox items selectable? 
 
Chioma Obunadike #:
Wow 9 years later and I have the same issue :( 
Please does anyone know why this is happening? 
Is there any additional code I have to add to make the combobox items selectable? 

It works. Show your code. 

 
Laszlo Tormasi #:

It works. Show your code. 

//+------------------------------------------------------------------+
//|                                                       Alerts.mq4 |
//|                                  Copyright 2023,Obunadike Chioma |
//|                                       https://www.t.me/devbidden |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023,Obunadike Chioma"
#property link      "https://t.me/devbidden"
#property version   "1.00"
#property strict
#property indicator_chart_window

#include <Controls\Dialog.mqh>
#include <Controls\Button.mqh>
#include <Controls\Edit.mqh>
#include <Controls\Panel.mqh>
#include <Controls\Label.mqh>
#include <Controls\SpinEdit.mqh>
#include <Controls\Button.mqh>
#include <Controls\ComboBox.mqh>

CAppDialog app;
CPanel panel;
CEdit edit1;
CButton btn1;
CComboBox cbox;
CComboBox box1;
CLabel label1;
CLabel label2;
CLabel label3;

#define PANEL_WIDTH 350
#define PANEL_HEIGHT 80
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   app.Create(0,"Alert Panel ",0, 0, 0,PANEL_WIDTH,PANEL_HEIGHT);

   int total = app.ControlsTotal();
   CWndClient*myclient;

   for(int i = 0; i < total; i++)
     {
      CWnd*obj = app.Control(i);
      string name = obj.Name();
      if(StringFind(name,"Client")>0)
        {
         CWndClient *client  = (CWndClient*)obj;
         client.ColorBackground(clrLavender);
         myclient= client;
         ChartRedraw();
        }
      if(StringFind(name,"Back")>0)
        {
         CPanel*panel2  = (CPanel*) obj;
         panel2.ColorBackground(clrLavender);
         ChartRedraw();
        }

      if(StringFind(name,"Caption")>0)
        {
         CEdit*edit  = (CEdit*) obj;
         edit.ColorBackground(clrLavender);
         ChartRedraw();
        }

      if(StringFind(name,"Border")>0)
        {
         CPanel*panel3  = (CPanel*) obj;
         panel3.ColorBorder(clrLavender);
         ChartRedraw();
        }
     }
   app.Run();
   app.Caption(" ");


   cbox.Create(0,"boxes",0,90,20,170,40);
   app.Add(cbox);
   cbox.AddItem("CA");
   cbox.AddItem("CB");
   string lot  = cbox.Select();
   Print (lot);
   cbox.ListViewItems(2);




   edit1.Create(0,"edit1",0,10,20,80,40);
   app.Add(edit1);

   box1.Create(0,"box1",0,180,20,260,40);

   app.Add(box1);
   box1.ItemAdd("Price",0);
   box1.ItemAdd("EMA",0);
   box1.ItemAdd("LOD",0);
   box1.ItemAdd("HOD",0);
   box1.ItemAdd("YH",0);
   box1.ItemAdd("YL",0);
   box1.ItemAdd("FH",0);
   box1.ItemAdd("FL",0);
   box1.Select(8);
   box1.ListViewItems(8);

   label1.Create(0,"label1",0,10,1,80,30);
   label1.Text("Price / EMA : ");
   label1.Font("Bahnschrift Light Condensed");
   label1.FontSize(12);
   label1.Color(clrBlack);
   app.Add(label1);

   label2.Create(0,"label2",0,90,1,170,30);
   label2.Text("Condition : ");
   label2.Font("Bahnschrift Light Condensed");
   label2.FontSize(13);
   label2.Color(clrBlack);
   app.Add(label2);

   label3.Create(0,"label3",0,180,1,260,30);
   label3.Text("Parameter : ");
   label3.Font("Bahnschrift Light Condensed");
   label3.FontSize(13);
   label3.Color(clrBlack);
   app.Add(label3);

   btn1.Create(0,"button",0,270,20,330,40);
   btn1.ColorBackground(clrLimeGreen);
   btn1.ColorBorder(clrBlack);
   btn1.Text("Set");
   app.Add(btn1);



   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);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

   app.Destroy(reason);
   box1.Destroy(reason);
   cbox.Destroy(reason);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
  {
   app.ChartEvent(id,lparam,dparam,sparam);
   box1.OnEvent(id,lparam,dparam,sparam);
   cbox.OnEvent(id,lparam,dparam,sparam);

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

This is the code mate 

 
Chioma Obunadike #:

Run the app only when all controls are added. 

So put 

   app.Run();

at the end of OnInit. 

As the Controls are added to the app which is a container and handles the Events, you don't need to do that for each control element: 

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
  {
   app.ChartEvent(id,lparam,dparam,sparam);
   /*box1.OnEvent(id,lparam,dparam,sparam);
   cbox.OnEvent(id,lparam,dparam,sparam);*/

   
  }

Same with destroying them: 

void OnDeinit(const int reason)
  {

   app.Destroy(reason);
   /*box1.Destroy(reason);
   cbox.Destroy(reason);*/
  }
 
Laszlo Tormasi #:

Run the app only when all controls are added. 

So put 

at the end of OnInit. 

As the Controls are added to the app which is a container and handles the Events, you don't need to do that for each control element: 

Same with destroying them: 

Thanks mate. You fixed it :)
Reason: