Is it possible to set OBJ_EDIT graphical component always on top?
I'm currently able to show it on top for existing component ( for example it overlays a trendline ) but it doesn't work for new components ( the user is able to draw a new trendline which is drawn over the OBJ_EDIT component ).
I'm actually using ObjectSetInteger(0,objName1,OBJPROP_ZORDER,0); but it doesn't work for new components.
Thanks
The order of overlaying of the objects is their creation order. Probably the only way is deleting and re-creating the objects in the desired order. The Z-order applies to the mouse click events only (at least the docs say so).
The order of overlaying of the objects is their creation order. Probably the only way is deleting and re-creating the objects in the desired order. The Z-order applies to the mouse click events only (at least the docs say so).
Exactly!
Here's a workaround example which saves the OBJ_EDIT state to file, deletes the chart-object, creates it again, and loads the object state from file.
#property strict #property indicator_chart_window //+------------------------------------------------------------------+ #include <ChartObjects\ChartObjectsTxtControls.mqh> class ForegroundEdit : public CChartObjectEdit { public: void BringToForeground() { string f = "temp/temp.bin"; int h=-1; if(m_chart_id >=0) { h = FileOpen(f,FILE_BIN|FILE_WRITE); Save(h); FileClose(h); } ObjectDelete(m_chart_id,m_name); ObjectCreate(m_chart_id,m_name,OBJ_EDIT,m_window,0,0,0); h=FileOpen(f,FILE_BIN|FILE_READ); Load(h); FileClose(h); } void OnChartEvent(int id,string sparam) { if(id==CHARTEVENT_OBJECT_CLICK && sparam == m_name) EventKillTimer(); if(id==CHARTEVENT_OBJECT_ENDEDIT && sparam == m_name) EventSetTimer(1); } void OnTimer() { BringToForeground(); } }; //+------------------------------------------------------------------+ ForegroundEdit edit; int OnInit() { edit.Create(0,"Foreground Edit",0,50,50,50,50); EventSetTimer(1); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnTimer() { edit.OnTimer(); } //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { edit.OnChartEvent(id,sparam); } //+------------------------------------------------------------------+ int start(){ return 0; }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Is it possible to set OBJ_EDIT graphical component always on top?
I'm currently able to show it on top for existing component ( for example it overlays a trendline ) but it doesn't work for new components ( the user is able to draw a new trendline which is drawn over the OBJ_EDIT component ).
I'm actually using ObjectSetInteger(0,objName1,OBJPROP_ZORDER,0); but it doesn't work for new components.
Thanks