I have spent a frustrating few hours attempting to rename an Rectangle object from a class function call inside the OnEvent.
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
m_Prime.ChartEvent(id, lparam, dparam, sparam);
I can get all the data from the created object and the build a new rectangle they way I want it. I then need to delete the original. But I can't. Even if I use DeleteAllObjects, it removes all object apart from the one in the Create event.
void Prime::ChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
if (ObjectGet(sparam, OBJPROP_TYPE) == OBJ_RECTANGLE)
ChartSetInteger(0, CHART_EVENT_OBJECT_CREATE, 0);
ChartSetInteger(0, CHART_EVENT_OBJECT_DELETE, 0);
Print("Event Create ..");
RectangleStuff(sparam); // Looks at the rectangle then builds a new one with a different name.
ChartSetInteger(0, CHART_EVENT_OBJECT_CREATE, 1);
ChartSetInteger(0, CHART_EVENT_OBJECT_DELETE, 1);
I have tried even setting a bool global variable for deletion outside of the main OnChartEvent, but that also would not work. My final thought was to let a tick go by and call a delete from OnCalculate but that just sounded absurd. So how do I end the relationship with the OnChartEvent and this rectangle object, so that I can delete it?
What's the error code returned by ObjectDelete() ?
Returns true if the removal was successful, otherwise returns false. To read more about the error call GetLastError().