How to change CAppDialog background color?

 
I need to change background color of my Panel derived from CAppDialog, but since m_background is a private member of CDialog, I can't access it and change the color with the function ColorBackground(). I appritiate any help.
 
Mohammad Mohi:
I need to change background color of my Panel derived from CAppDialog, but since m_background is a private member of CDialog, I can't access it and change the color with the function ColorBackground(). I appritiate any help.

Just create your own panel "CPanel" ...

This example is based on a standard of Example ...\MQL5\Experts\Examples\Controls\

Files:
 
Karputov Vladimir:

Just create your own panel "CPanel" ...

This example is based on a standard of Example ...\MQL5\Experts\Examples\Controls\

Thanks for reply, But I want to change the main CAppDialog background color or caption bar, not the controls on it.
 
Mohammad Mohi:
Thanks for reply, But I want to change the main CAppDialog background color or caption bar, not the controls on it.
Extend my plate - and you can change the background color :). By CAppDialog not have access.
 
Karputov Vladimir:
Extend my plate - and you can change the background color :). By CAppDialog not have access.
That's fine, I know that way but I need to code as less as possible, and want to benefit from further developments made to the Standard Library, that's why I want to try a native way rather than extending, I believe one should be able to change the Panel colors within the inherited class itself.
 
The simplest way would be to move m_background to protected: but then the code would have to be changed when the class is updated.
 

Mohammad, how did you solve this?

I have same problem and any way I look at it, it's a lot of hassle. Either I have to change core lib and then keep changing it after every update, or I have to write a sh11ton of code, classes that inherit the core lib but afterward serves basically nothing else.

 

I created a new public method on CDialog class to change background color:

bool CDialog::setBackColor(color uColor)
{
   if(!m_white_border.ColorBackground(uColor))
      return(false);
   if(!m_background.ColorBackground(uColor))
      return(false);
   if(!m_client_area.ColorBackground(uColor))
      return(false);
   
   return true;
}


...then, I can change background color after do the Create method of Dialog object.

I hope it help you...

 
Mauricio Costa:

I created a new public method on CDialog class to change background color:


...then, I can change background color after do the Create method of Dialog object.

I hope it help you...


thank bro

 
Mauricio Costa: I created a new public method on CDialog class to change background color:
bool CDialog::setBackColor(color uColor)
{
   if(!m_white_border.ColorBackground(uColor))
      return(false);
   if(!m_background.ColorBackground(uColor))
      return(false);
   if(!m_client_area.ColorBackground(uColor))
      return(false);
   
   return true;
}
Simplify your code. Increase Order after stoploss - MQL4 and MetaTrader 4 - MQL4 programming forum
 
aries:

Mohammad, how did you solve this?

I have same problem and any way I look at it, it's a lot of hassle. Either I have to change core lib and then keep changing it after every update, or I have to write a sh11ton of code, classes that inherit the core lib but afterward serves basically nothing else.


https://www.mql5.com/en/articles/4575#para4
Improving Panels: Adding transparency, changing background color and inheriting from CAppDialog/CWndClient
Improving Panels: Adding transparency, changing background color and inheriting from CAppDialog/CWndClient
  • www.mql5.com
CAppDialog class based panels lack methods for direct access to the properties of controls which the panel is made of, such as the Background color and the Frame color. Therefore, all created panels are gray.  It is not possible to implement design ideas without the ability to change the color of controls. This problem could be solved by...