Discussion of article "Adding a control panel to an indicator or an Expert Advisor in no time" - page 2

 
Maxim Dmitrievsky:

Well, that's what I did, nothing works. The panel is still white as before.

The compiler says Macro redifinition, i.e. like overdivided....

Use my first advice, just replace the colours in the original file and recompile the EA.

To remember how I redefined the colours in my panel, I need to dig around, but I don't have time right now.

 

For History:

Forum on trading, automated trading systems and testing trading strategies

Why does the panel move away when updating Expert Advisor settings?

Andrey Khatimlianskii, 2016.03.10 13:17

Approximately like this:

// BEFORE connecting Dialog.mqh!
#include <Controls\Defines.mqh>

//--- Forget the old colours
#undef   CONTROLS_DIALOG_COLOR_BORDER_LIGHT
#undef   CONTROLS_DIALOG_COLOR_BORDER_DARK
#undef   CONTROLS_DIALOG_COLOR_BG
#undef   CONTROLS_DIALOG_COLOR_CAPTION_TEXT
#undef   CONTROLS_DIALOG_COLOR_CLIENT_BG
#undef   CONTROLS_DIALOG_COLOR_CLIENT_BORDER

//--- Set new colours
#define  CONTROLS_DIALOG_COLOR_BORDER_LIGHT  clrWhite            // Dialog border colour (outside)
#define  CONTROLS_DIALOG_COLOR_BORDER_DARK   C'0xB6,0xB6,0xB6'   // Dialog border colour (inside)
#define  CONTROLS_DIALOG_COLOR_BG            clrLightGreen       // Dialog background (under the caption and around the client area)
#define  CONTROLS_DIALOG_COLOR_CAPTION_TEXT  C'0x28,0x29,0x3B'   // Dialog caption text colour
#define  CONTROLS_DIALOG_COLOR_CLIENT_BG     clrAliceBlue        // Client area background colour
#define  CONTROLS_DIALOG_COLOR_CLIENT_BORDER C'0xC8,0xC8,0xC8'   // Client area colour

// Now connect
#include <Controls\Dialog.mqh>

 

Can you give me a simple example of how CWndContainer should be twisted to display at least some square on the chat screen using .Show()?

I have tried everything, for example, like this, but no error, no image, no sign of .Show() working

#include <Controls\WndContainer.mqh>

class MyWndContainer : public CWndContainer  {
   public:
      MyWndContainer(string name);
};

//+------------------------------------------------------------------+
//| Constructor|
//+------------------------------------------------------------------+
MyWndContainer::MyWndContainer(string name) {
   m_chart_id = ChartID();
   m_subwin = 0;
   m_name = name;
                   m_id = 0;
                   m_align_top = 5;
                   m_align_right = 5;
                   m_align_left = 5;
                   m_align_bottom = 5;
                   m_mouse_x = 100;
                   m_mouse_y = 100;
                   m_align_flags = ALIGN_CENTER;
                   m_prop_flags = PROGRAM_EXPERT;
                   m_mouse_flags = MOUSE_EMPTY;
} 
 
Evgeny Potapov:

Can you give me a simple example of how CWndContainer should be twisted to display at least some square on the chat screen using .Show()?

I have tried everything, for example, like this, but no error, no image, no sign of .Show() working.

Why CWndContainer? What should you get in the end?
 

I don't understand the logic here:

//+------------------------------------------------------------------+
//| Makes the group of controls visible |
//+------------------------------------------------------------------+
bool CWndContainer::Show(void)
  {
//--- loop by elements of group
   int total=m_controls.Total();
   for(int i=0;i<total;i++)
     {
      CWnd *control=Control(i);
      //--- check of pointer
      if(control==NULL)
         continue;
      control.Show();
     }
//--- call of the method of the parent class
   return(CWnd::Show());
  }

What if I have a Button object and it doesn't have a .Show() method.

Can't it be contained in a container?

 
Karputov Vladimir:
Why CWndContainer? What should we get in the end?
A panel with Buy - Sell buttons and some more notifications about the state of the Expert Advisor. But it should be dragged on the screen with the mouse, but the button is not dragged.
 
Evgeny Potapov:
A panel with Buy - Sell buttons and some more notifications about the state of the Expert Advisor. But it should be dragged on the screen with the mouse, but the button is not dragged.
After creating an object (button, list, text field, etc.) this object should be added to the panel (Add method). Then, when dragging the panel, all objects will be moved together with the panel.
 
Karputov Vladimir:
After creating an object (button, list, text field, etc.) this object should be added to the panel (Add method). Then when dragging the panel, all objects will be moved together with the panel.

Like this?

#include <Controls\Button.mqh>
#include <MyControls\MyWndContainer.mqh>

CButton *MyButton;
CWndContainer  *MyContainer;
//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()  {
   MyButton = new CButton;
   if(CheckPointer(MyButton) == POINTER_INVALID) return(INIT_FAILED);
   MyButton.Create(ChartID(),WindowExpertName()+"_button",0,50,100,150,250);

   MyContainer = new MyWndContainer("MyContainer");
   if(CheckPointer(MyContainer) == POINTER_INVALID) return(INIT_FAILED);
   MyContainer.Add(MyButton);
   MyContainer.Show();
   MyContainer.Enable();

   
   return(INIT_SUCCEEDED);
}
 
Karputov Vladimir:
After creating an object (button, list, text field, etc.) this object should be added to the panel (Add method). Then, when dragging the panel, all objects will be moved together with the panel.

Or is this not "adding to the panel"?

So a container is not a panel?

 
Evgeny Potapov:

Or is it not "adding to a panel"?

So a container is not a panel?

Using the PanelDialog2.mqh file from the article as an example:

//+------------------------------------------------------------------+
//|PanelDialog2.mqh |
//| Copyright 2015, MetaQuotes Software Corp. | |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#include <Controls\Dialog.mqh>
#include <Controls\CheckGroup.mqh>
#include <Controls\Label.mqh>
#include <Controls\Edit.mqh>
#include <Controls\Button.mqh>
//+------------------------------------------------------------------+
//| defines|
//+------------------------------------------------------------------+
//--- indents and gaps
#define  INDENT_LEFT                         (11)      // indent from left (with allowance for border width)
#define  INDENT_TOP                          (11)      // indent from top (with allowance for border width)
#define  INDENT_RIGHT                        (11)      // indent from right (with allowance for border width)
#define  INDENT_BOTTOM     

This file creates the elements for a dialogue panel. The sign of the panel is the CDialog class.

CDialog class

The CDialog class is a class of the Dialog combo control.

Description

The CDialog class is designed to visually combine a group of functionally related heterogeneous elements.