How to change CAppDialog background color? - page 2

 

As a developer I was very frustrated too for not having control over such a useful property, which is backcolor.

Searched the possibilities, and, even not being an OOP expert, decided take the chances and change the TextBox control, including this public method:

   void   SetBackColor(const color clr)  { m_back_color=clr; }

Now it is very easy setting the TextBox background color:

CTextEdit  m_txt;

m_txt.GetTextBoxPointer().SetBackColor(clrYellow);

Now I need to be careful when updating the EasyAndFastGUI package, but I think it is worth
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
  • www.mql5.com
Program Properties (#property) - Preprocessor - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

You can try this method to add to your derived CAppDialog class:

//+--------------------------------------------------------------------------------------------------------------------------------------------------
//+ Sets AppDialog background color
//+--------------------------------------------------------------------------------------------------------------------------------------------------
void MyAppDialog::ColorBackground(const color clr)
{
    string prefix=Name();
    int total=ControlsTotal();
    for(int i=0;i<total;i++)
    {
        CWnd*obj=Control(i);
        string name=obj.Name();
        if(name==prefix+"Client")
        {
            CWndClient *wndclient=(CWndClient*) obj;
            wndclient.ColorBackground(clr);
            ChartRedraw();
            return;
        }
    }
}


then use it in EA after the creation of AppDialog:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    App=new CMyAppDialog();
    App.Create(0,0, //...your params);
    App.ColorBackground(clrYellow);  // new method to change the background color
    App.Run();
    .
    .
    .
}
Reason: