For any element you want to get "OnActivate"? On the basis of class CBmpButton or another?
Hi - I can get it to fire for a CBmpButton inside the CWndContianer, but no matter what I try I can't get the CWndContianer.OnActivate to fire. Thanks Dan.
mytradertools :
Hi - I can get it to fire for a CBmpButton inside the CWndContianer, but no matter what I try I can't get the CWndContianer.OnActivate to fire. Thanks Dan.
Show your code.
Hi - I can get it to fire for a CBmpButton inside the CWndContianer, but no matter what I try I can't get the CWndContianer.OnActivate to fire. Thanks Dan.
barabashkakvn:
Show your code.
Show your code.
Hi - here it is. (Apologies for the lateness of the reply)
#include <Controls\Dialog.mqh> #include <Controls\WndContainer.mqh> #include <Controls\Panel.mqh> //////////////////////////////////////////////////////////////////////////// // *********************************************************************** // CWndContainerTest Class // - to test the firing of OnResize - working and OnActivate - NOT working. class CWndContainerTest: public CWndContainer { private: CPanel m_panel; // chart object public: CWndContainerTest(); ~CWndContainerTest(); //--- 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); protected: //--- internal event handlers virtual bool OnResize(void); virtual bool OnActivate(void); }; CWndContainerTest::CWndContainerTest() { } CWndContainerTest::~CWndContainerTest() { } //+------------------------------------------------------------------+ //| Create a control | //+------------------------------------------------------------------+ bool CWndContainerTest::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2) { //--- call method of the parent class if(!CWndContainer::Create(chart,name,subwin,x1,y1,x2,y2)) return(false); //--- create the chart object if(!m_panel.Create(chart,name+"panel",subwin,0,0,Width(),Height())) return(false); m_panel.ColorBorder(clrBlack); Add(m_panel); return(true); } // OnResize - works ok. bool CWndContainerTest::OnResize(void) { Print("OnResize Working"); //--- call of the method of the parent class return(CWndContainer::OnResize()); } // OnActivate - CANT GET THIS TO FIRE. bool CWndContainerTest::OnActivate(void) { // WONT FIRE. Print("Can't get this to fire!!!!!"); //--- call of the method of the parent class return(CWndContainer::OnActivate()); } // ***************************************************** //////////////////////////////////////////////////////// // variables to hold the chart objects CWndContainerTest m_container; CAppDialog m_dialog; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { // create the dialog. m_dialog.Create(ChartID(), "AppDialog1", 0, 20,20,400,200); // create and add the windows container. m_container.Create(ChartID(), "Container1", 0, 20, 20, 170, 42); m_dialog.Add(m_container); // run the dialog. m_dialog.Run(); // for the onReszie to fire m_container.Width(m_container.Width() - 1); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- Call the Dialog event handler. m_dialog.ChartEvent(id, lparam,dparam,sparam); } //+------------------------------------------------------------------+
Share your code into two files: an indicator and class. (For example, a file from the folder: ...\Terminal\*** 8209F7...F37..BF55...1FF075\MQL5\Indicators\Examples\Panels\SimplePanel).
barabashkakvn:
Share your code into two files: an indicator and class. (For example, a file from the folder: ...\Terminal\*** 8209F7...F37..BF55...1FF075\MQL5\Indicators\Examples\Panels\SimplePanel).
Share your code into two files: an indicator and class. (For example, a file from the folder: ...\Terminal\*** 8209F7...F37..BF55...1FF075\MQL5\Indicators\Examples\Panels\SimplePanel).
Hi barabashkakvn - I have attached the two files as requested. Kind regards Dan.
Files:
It does not work.
//+------------------------------------------------------------------+ //| WndContainer.mqh | . . . virtual bool Save(const int file_handle); virtual bool Load(const int file_handle); protected: //--- internal event handlers virtual bool OnResize(void); virtual bool OnActivate(void); virtual bool OnDeactivate(void); };
mytradertools :
Do you mean my code does not compile and run, or the OnActivate() of CWndContainter does not work? Regards.
Pay attention to control CBmpButton. In this control OnActivate () will work.
Yes, agreed - CBmpButton OnActivate works fine, I can get that to fire ok and it descends CWndObj not CWndContainer.
I can't get CWndContainer to fire and I can't see that I am doing anything wrong. Thanks Dan.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all,
Has anyone got the bool CWndContainer::OnActivate to fire? I need to know when the container is active so I can put a highlight around the control, but i just can't seem to get it to fire and I have tried lots of different methods.
Any help will be greatly appreciated.
Kind regards
Dan.