Some Problem with Control development.

 

Dear Guys,

I am developed Panel with control. But i am facing some problem.

 

 

Problem 1 : when i click ComboBox then  combo data not show.  I can't change others data.

Problem 2 : When i try to write something on text box. writing data not show when i am writing. Data show when i move text control to others control. I notice when i delete red code below from my EA then text problem gone. 

void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam){

    ExtDialog.ChartEvent(id,lparam,dparam,sparam);
}

 

Problem 2 : Close button not work. panel not close.

 

Here the below all code:

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

CAppDialog        ExtDialog;
CLabel            m_lbl_Close;
CPanel            m_ret_Rect;
CPanel            m_ret_Rect2;

CComboBox         m_com_Risk;
CEdit             m_txt_Lots; 

int OnInit(){
  
  m_Symbol= _Symbol;
  if(ExtDialog.Create(0,m_Symbol,m_subwin,10,30,m_client_area,150)){
     CreateLine_3();
  }else return(-1);

      
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){
   ExtDialog.Destroy(reason);
}


void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam){

    ExtDialog.ChartEvent(id,lparam,dparam,sparam);
}


bool CreateLine_3()
{
   int left    = INDENT_LEFT;
   int top     = GlobalTop+6;
   int width   = INDENT_LEFT+BUTTON_LEFT; 
   int hight   = top+BUTTON_HEIGHT2;
   GlobalTop   = hight;

   if(m_com_Risk.Create(m_chart_id,m_name+"Risk",m_subwin,left,top,width,hight)){
     m_com_Risk.ItemAdd("Fixed");
     m_com_Risk.ItemAdd("Equity %");
     m_com_Risk.ItemAdd("Risk %");
     ExtDialog.Add(m_com_Risk);
   }
   m_com_Risk.SelectByValue(0);
   
   left    = width+CONTROLS_GAP_X;
   width   = left+BUTTON_WIDTH;
   
   if(m_txt_Lots.Create(m_chart_id,m_name+"Lots",m_subwin,left,top,width,hight)){
      m_txt_Lots.Text("0.01");ExtDialog.Add(m_txt_Lots);
   }

   return(true);
}

 

 Please someone help me to solve this problem.

 

Thanks 

 

Hi!


Your code doesn't compile under my MT4.

Please include all your code.

 
eddie:

Hi!


Your code doesn't compile under my MT4.

Please include all your code.


 

I attach full code file. 

Files:
 
is anyone can help me out?
 

Hi capilta!

Try

int OnInit(){
 
  m_Symbol= _Symbol;
  if(ExtDialog.Create(0,m_Symbol,m_subwin,10,30,m_client_area,150)){
     CreateLine_3();
    
  }else return(-1);

  ExtDialog.Run ( );
     
   return(INIT_SUCCEEDED);
}


eddie

 
eddie:

Hi capilta!

Try

int OnInit(){
 
  m_Symbol= _Symbol;
  if(ExtDialog.Create(0,m_Symbol,m_subwin,10,30,m_client_area,150)){
     CreateLine_3();
    
  }else return(-1);

  ExtDialog.Run ( );
     
   return(INIT_SUCCEEDED);
}


eddie

 

 Many Many thanks eddie. it is working now. Just give me two more help.

 1. what ever i set in text box. but when i change timeframe  text box or combobox data going to default value. How do save my data what ever i set data will not change when i change timeframe.

 2. How to use comboBox change event. In the class i can maping event with any procedure. like :

 

EVENT_MAP_BEGIN(CHedgePanel)
   ON_EVENT(ON_CLICK, m_pos_open, OnClickPositionsOpen)
   ON_EVENT(ON_CLICK, m_pos_close, OnClickPositionsClose)
EVENT_MAP_END(CAppDialog)

 but i can't use this code in my expart adviser file. How can i use comboBox event or text box event. 

 

It will be great eddie help me. 

 

Hi capilta!

1. If you change timeframe or symbol, the EA will restart and all your data get lost.

In OnDeinit you have to store data outside the EA and load them on OnInit (write data in a file like INI or XML).


2. The ON_CLICK Event is for Buttons.

To check ComboBoxes and Text fields you have to check the ON_CHANGE event.

eddie

 
Thank you eddie. Your codes are great.
Reason: