Below in the coded section, I have a CGraphicalPanel class representing my Panel.
But I see when minimized the panel in X dimension, bit too narrow.
How would I change the the size of the panel when minimized?
Would like the panel to be large in X dimension when minimized.
All I know that CAppDialog >> CDialog has a `m_min_rect` variable, I presume this has to do with the size when minimized, but it would like to change this during the initialization of my panel called CGraphicalPanel.
Well, figured it out, by redefining:
CONTROLS_DIALOG_MINIMIZE_WIDTH
//+------------------------------------------------------------------+ //| Include 1 | //+------------------------------------------------------------------+ #include "MT5_GB-Logger_static.mqh" #include <Controls\Defines.mqh> // IMPORT THEN REDEFINE BEFORE OTHER CONTROL IMPORTS //+------------------------------------------------------------------+ //| Define statements to change default dialog settings | //+------------------------------------------------------------------+ // Undefine before re-defining #undef CONTROLS_FONT_NAME #undef CONTROLS_DIALOG_COLOR_CLIENT_BG #undef CONTROLS_DIALOG_MINIMIZE_WIDTH // Re-defining #define CONTROLS_FONT_NAME "Consolas" #define CONTROLS_DIALOG_COLOR_CLIENT_BG C'0x20,0x20,0x20' #define CONTROLS_DIALOG_MINIMIZE_WIDTH 200 // THIS CHANGES MINIMIZED PANEL WIDTH
In MQL5 Standard Library in documentation there is a method Minimized() from CAppDialog (which you are using), you can set it to true or false.
A note for anyone who finds this thread later: the #define changes the default minimized width, but two problems can still remain.
1. The first Minimize jumps to the top-left corner. If m_minimized is already true when you call Create() (for example when you restore a saved minimized state after a timeframe change), CAppDialog::Create() calls Minimize() at the end, and for an EA m_min_rect still holds the default bounds set in CreateExpert() (10,10,110,36). m_minimized is now true, so an if(!m_minimized) guard blocks your own Minimize() with the correct size.
2. After a timeframe change the minimized width shrinks, because the width is taken from m_rect, which is already small in the minimized state.
What worked for me (tested on MT5 build 6230). Minimize() is protected, so it is called from a method of the derived class:
class CStableDialog : public CAppDialog
{
public:
void ResetMinimizedFlag(void) { m_minimized = false; }
void MinimizeWithNormalWidth(void)
{
int w = m_norm_rect.Width(); // width of the normal state, not m_rect
m_min_rect.SetBound(m_rect.left, m_rect.top,
m_rect.left + w, m_rect.top + CONTROLS_DIALOG_MINIMIZE_HEIGHT);
if(!m_minimized)
Minimize();
}
};Order:
- Create the dialog in its normal state, then call ResetMinimizedFlag().
- Move the dialog to its final position, so m_rect holds the right left/top.
- Then call MinimizeWithNormalWidth().
Full example with timeframe changes and saved state: https://www.mql5.com/en/blogs/post/776908
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Below in the coded section, I have a CGraphicalPanel class representing my Panel.
But I see when minimized the panel in X dimension, bit too narrow.
How would I change the the size of the panel when minimized?
Would like the panel to be large in X dimension when minimized.
All I know that CAppDialog >> CDialog has a `m_min_rect` variable, I presume this has to do with the size when minimized, but it would like to change this during the initialization of my panel called CGraphicalPanel.