Control classes without CDialog - How to work with CComboBox(), CListView(), CSpinEdit and so on ...
Hi there,
I startet to write my own set of classes to create a own panel. Everything is (almost) fine so far, but those classes, which are derived from CWndContainer simply don't want to work. These are CComboBox, CListView and CSpinEdit. The controls are shown, but there is no interaction/reaction when I click on them. Whats the trick? Anybody an idea?
Of course I've passed the parameters from OnChartEvent() to their OnEvent() function, but nothing happens. CButton Objects by the way don't act correctly when I click on them, because the .Locking() property is not interpreted, but I guess it's the same reason as with the other controls.
Imam totally new to MQL, but have lots of experience with C++ and I was really wondering, whats possible with MQL. Great job by the developers, chapeau!
Doerk
Hi,
thanks for your reply. It´s just like that. Actually, the button should not lock and the combo should show a drop down-list, but neither the one nor the other happens.
Thanks in advance
//+------------------------------------------------------------------+ //| ControlTest.mq4 | //+------------------------------------------------------------------+ #property strict #include <Controls\Button.mqh> #include <Controls\ComboBox.mqh> CButton b; CComboBox c; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- if (!b.Create(NULL,"Button",NULL,0,0,200,100)) return(INIT_FAILED); b.Text("Click"); b.Locking(False); if (!c.Create(NULL,"Combo",NULL,0,120,300,140)) return(INIT_FAILED); c.AddItem("Item 1",1); c.AddItem("Item 2",2); c.AddItem("Item 3",3); c.Select(0); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- b.OnEvent(id,lparam,dparam,sparam); c.OnEvent(id,lparam,dparam,sparam); } //+------------------------------------------------------------------+
OK, reason for the problem with the buttons behavior found by myself. If you add this somewhere in your code, i. E. during OnInit(), the button reacts correctly. But still no reason for the problem with CComboBox and/or CSpinEdit. It cannot be that complicated, but CDialog or any other class above seems to do anything that I cannot figure out at the moment.
ChartSetInteger(NULL,CHART_EVENT_MOUSE_MOVE, true); ChartSetInteger(NULL,CHART_EVENT_OBJECT_CREATE,true); ChartSetInteger(NULL,CHART_EVENT_OBJECT_DELETE, true);
For the control of the CButton class based you can select such handlers:
//+------------------------------------------------------------------+ //| Wnd.mqh | //| Copyright 2009-2013, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ . . . protected: //--- internal event handlers virtual bool OnCreate(void) { return(true); } virtual bool OnDestroy(void) { return(true); } virtual bool OnMove(void) { return(true); } virtual bool OnResize(void) { return(true); } virtual bool OnEnable(void) { return(true); } virtual bool OnDisable(void) { return(true); } virtual bool OnShow(void) { return(true); } virtual bool OnHide(void) { return(true); } virtual bool OnActivate(void) { return(true); } virtual bool OnDeactivate(void) { return(true); } virtual bool OnClick(void); virtual bool OnDblClick(void); virtual bool OnChange(void) { return(true); } //--- mouse event handlers virtual bool OnMouseDown(void); virtual bool OnMouseUp(void); //--- handlers of dragging virtual bool OnDragStart(void); virtual bool OnDragProcess(const int x,const int y); virtual bool OnDragEnd(void); //--- methods for drag-object virtual bool DragObjectCreate(void) { return(false); } virtual bool DragObjectDestroy(void); }; //+------------------------------------------------------------------+ //| Common handler of chart events | //+------------------------------------------------------------------+
Of them actually can use only this: (implemented in Button1)
virtual bool OnActivate(void) { return(true); } virtual bool OnDeactivate(void) { return(true); }
Thank you again for your effort. But I still don't have a clue how I can convince this control to do its job - outside - a CDialog environment :) I dont want to use the CDialog Class at all, just the CComboBox() control i. E. on a plain chart-screen with nothing else around it.
Any ideas more?
Thank you again for your effort. But I still don't have a clue how I can convince this control to do its job - outside - a CDialog environment :) I dont want to use the CDialog Class at all, just the CComboBox() control i. E. on a plain chart-screen with nothing else around it.
Any ideas more?
If it works with the panel, there must be a solution how to make it work also without, cause the CDialog is n not a kind of a wizard ;)
Anyway, I am one step further: If I use the debugger, and go through step by step, the List drops down, but when I simply let it run, it does not. WTF? :D I will figure it out ;)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
I startet to write my own set of classes to create a own panel. Everything is (almost) fine so far, but those classes, which are derived from CWndContainer simply don't want to work. These are CComboBox, CListView and CSpinEdit. The controls are shown, but there is no interaction/reaction when I click on them. Whats the trick? Anybody an idea?
Of course I've passed the parameters from OnChartEvent() to their OnEvent() function, but nothing happens. CButton Objects by the way don't act correctly when I click on them, because the .Locking() property is not interpreted, but I guess it's the same reason as with the other controls.
Imam totally new to MQL, but have lots of experience with C++ and I was really wondering, whats possible with MQL. Great job by the developers, chapeau!
Doerk