Adding rectanglelabel to a panel

 

hello guys,

I have created a panel with several controls and labels on (code not shown but working) - for aesthetic reasons I wanted to add some separator lines at various places and I am trying to do this with a rectanglelabel purely for ease of being able to use x,y coord placement.

The 'Add' function call obviously is the wrong call for what I am trying to do which is to 'bind' the rectanglelabel to the panel.

Is anybody able to point me in the right direction to be able to do this please?

#include <Controls\Defines.mqh>
#include <Controls\Dialog.mqh>
#include <Controls\Label.mqh>
#include <Controls\Panel.mqh>
#include <Controls\Button.mqh>
#include <Controls\RadioButton.mqh>
#include <ChartObjects\ChartObjectsTxtControls.mqh>


CChartObjectRectLabel  rect;


int OnInit()
{
rect.Create(0,"rect",0,10,220,200,1);
rect.Add(????)
}
 
I give you a sample program.
Files:
MyPanel.mq4  5 kb
 
Nagisa Unada:
I give you a sample program.

Thanks for the reply - I took your code and tried to add a RectangleLabel using documentation from here: https://www.mql5.com/en/docs/standardlibrary/chart_object_classes/obj_controls/cchartobjectrectlabel

So adding the following:

#include <ChartObjects\ChartObjectsTxtControls.mqh>

CChartObjectRectLabel rectlab;

int OnInit()
{
        //--- Panel create
        m_panel.Create(0, "TEST PANEL", 0, panelXX, panelYY, panelWidth, panelHeight);
        
        rectlab.Create(0,"rect",0,10,220,200,1);
        m_panel.Add(rectlab);

        //--- Run panel
        m_panel.Run();
        return(0);
}

The label is drawn independently but when compiling the 'Add' function I get this:

result

Documentation on MQL5: Standard Library / Graphic Objects / Control Objects / CChartObjectRectLabel
Documentation on MQL5: Standard Library / Graphic Objects / Control Objects / CChartObjectRectLabel
  • www.mql5.com
Standard Library / Graphic Objects / Control Objects / CChartObjectRectLabel - Reference on algorithmic/automated trading language for MetaTrader 5