text doesn't display on cDailog New comment Timothy Odoabuchi 2024.08.20 11:37 i have below script, the text displays on the chart directly instead of displaying inside the cdailog. what the solution? #include <Controls\Dialog.mqh> class CInfoPanel : public CDialog { private: bool m_created; public: CInfoPanel() : CDialog(), m_created(false) {} bool CreatePanel(long chart_id, int x, int y, int width, int height, const string &infoText) { // Create the dialog if (!CDialog::Create(chart_id, "Information", 0, x, y, width, height)) return false; // Create the label object if (!ObjectCreate(chart_id, "InfoLabel", OBJ_LABEL, 0, 0, 0)) { Print("Failed to create InfoLabel object"); return false; } // Set basic label properties ObjectSetInteger(chart_id, "InfoLabel", OBJPROP_XDISTANCE, 15); ObjectSetInteger(chart_id, "InfoLabel", OBJPROP_YDISTANCE, 15); // Adjusted Y-distance for better visibility ObjectSetInteger(chart_id, "InfoLabel", OBJPROP_XSIZE, width - 30); ObjectSetInteger(chart_id, "InfoLabel", OBJPROP_YSIZE, height - 30); ObjectSetInteger(chart_id, "InfoLabel", OBJPROP_COLOR, clrBlack); // Set text color ObjectSetInteger(chart_id, "InfoLabel", OBJPROP_CORNER, CORNER_LEFT_UPPER); ObjectSetInteger(chart_id, "InfoLabel", OBJPROP_FONTSIZE, 12); // Set font size ObjectSetInteger(chart_id, "InfoLabel", OBJPROP_BACK, true); // Enable background // Set the text for the label if (!ObjectSetString(chart_id, "InfoLabel", OBJPROP_TEXT, infoText)) { Print("Failed to set InfoLabel text"); return false; } Print("InfoLabel text set successfully"); ChartRedraw(chart_id); m_created = true; return true; } void Destroy() { if (m_created) { Print("CInfoPanel::Destroy - Destroying panel..."); ObjectDelete(0, "InfoLabel"); CDialog::Destroy(); m_created = false; Print("CInfoPanel::Destroy - Panel destroyed."); } } bool IsCreated() const { return m_created; } void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { if (id == CHARTEVENT_OBJECT_CLICK) { if (sparam == "InformationClose") { this.Destroy(); } } } }; Samuel Manoel De Souza 2024.08.20 13:18 #1 Check the code example SimplePanel New comment
i have below script, the text displays on the chart directly instead of displaying inside the cdailog.
what the solution?