You have to use following code (or similar) in OnChartEvent().
m_ib.Event(id,lparam,dparam,sparam);
There is my full code what I am trying to test:
//+------------------------------------------------------------------+ //| eIncGUI_v3_Test_Form.mq5 | //| Copyright 2011, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2011, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #include <IncGUI_v3.mqh> enum eColorScheme{ DefaultScheme=0, YellowBrownScheme=1, BlueScheme=2, GreenScheme=3, YellowBlackScheme=4, LimeBlackScheme=5, AquaBlackScheme=6 }; input eColorScheme ColorScheme=DefaultScheme; class MyCForm: public CFormBase{ public: // 1. Declaring the controls CInputBox m_ib; CButton m_but; protected: // 2. Declaring the variables to restore the control values int m_EventsCounter; void MainProperties(){ // Setting the form parameters m_Name = "Form"; // Form name. The names of all the controls should start with it. m_Width = 260; // Form width m_Height = 200; // Form height m_Type = 1; // Form type: 0 - without buttons, 1 - with "Apply" and "Cancel" buttons, 2 - with the "Close" button m_Caption = "FormCaption"; // Form caption m_Movable = true; // Movable form (the button with a hand image is displayed in the top left corner) m_Resizable = true; // Form minimizing/maximizing allowed (the button with a rectangle image is displayed in the top right corner) m_CloseButton = false; // Form closing allowed (the button with a cross image is displayed in the top right corner) } void OnInitEvent(){ m_ib.Init(m_Name+"_IB",40,2); m_but.Init(m_Name+"_But",50,15); } void OnShowEvent(int aLeft,int aTop){ m_ib.Show(frm.Left()+40,frm.Top()+100); m_but.Show(frm.Left()+140,frm.Top()+100); } void OnHideEvent(){ m_ib.Hide(); m_but.Hide(); } void EventsHandler(const int id,const long& lparam,const double& dparam,const string& sparam){ string val=m_ib.ValueString(); if(m_but.Event(id,lparam,dparam,sparam)==1) { Alert("Mbut event: " + val);} } bool OnApplyEvent(){ // 11. Checking the control values upon closing by the "Apply" button. In order to reject the closing of the form, false should be returned from this method. // 12. Saving the parameters. string val=m_ib.ValueString(); Alert("Apply event: " + val); return(true); } bool OnCancelEvent(){ // 13. Checks upon closing by the "Cancel" or "Close" buttons. In order to reject the closing of the form, false should be returned from this method. return(false); } }; MyCForm frm; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit(){ //ClrScheme.SetScheme(ColorScheme); // Main form frm.Init(); frm.Show(30,30); return(0); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason){ frm.Hide(); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick(){ } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam ){ int ev=frm.Event(id,lparam,dparam,sparam); switch(ev){ case 1: Alert("Form "+frm.Name()+"("+frm.Caption()+"). Cancel event"); break; case 2: Alert("Form "+frm.Name()+"("+frm.Caption()+"). Apply event"); break; case 3: Alert("Form "+frm.Name()+"("+frm.Caption()+"). Resize event"); break; m_ib.Event(id,lparam,dparam,sparam); } }
I added m_ib.Event(id,lparam,dparam,sparam); in OnChartEvent at end of the code, but it caused error 'm_ib' - undeclared identifier. Strange that frm (what i s also in OnChartEvent) is not undeclared identifier. Where is difference, what I did wrong?
There is my full code what I am trying to test:
I added m_ib.Event(id,lparam,dparam,sparam); in OnChartEvent at end of the code, but it caused error 'm_ib' - undeclared identifier. Strange that frm (what i s also in OnChartEvent) is not undeclared identifier. Where is difference, what I did wrong?
Of course when I wrote "similar", it means you have to think a little where and how to place this code
Add the line in MyCForm :
void EventsHandler(const int id,const long& lparam,const double& dparam,const string& sparam){ m_ib.Event(id,lparam,dparam,sparam); string val=m_ib.ValueString(); if(m_but.Event(id,lparam,dparam,sparam)==1) { Alert("Mbut event: " + val);} }
or use this in OnChartEvent :
frm.m_ib.Event(id,lparam,dparam,sparam);
frm is an instance of MyCForm declared globally. So accessible everywhere in your EA.
m_ib is a property of this object.
So you can either place this line inside your class or in OnChartEvent.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I declared the control Inputbox :
CInputBox m_ib; (As in sample https://www.mql5.com/en/articles/322)
, Placed button event that must print in alert box that inputbox value :
if(m_but.Event(id,lparam,dparam,sparam)==1) {
Alert("Mbut event: " + m_ib.ValueString());}
, but I cannot see in my alertbox m_ib string ("MyText") what I want (Instead of "MyText" there is "0.00").
How I can succeed the right value in Mbut event?
Thank you!