Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 is an object-oriented language?
MetaQuotes Software Corp.
MetaQuotes Software Corp. 2016.03.31 15:07 

New article Graphical Interfaces II: The Main Menu Element (Chapter 4) has been published:

This is the final chapter of the second part of the series about graphical interfaces. Here, we are going to consider the creation of the main menu. The development of this control and setting up handlers of the library classes for correct reaction to the user's actions will be demonstrated here. We will also discuss how to attach context menus to the items of the main menu. Adding to that, we will mention blocking currently inactive elements.

Developing the Class for Creating the Main Menu

Classes for creating all elements for building the main menu of the program were developed in the previous three chapters. We have the following classes:

  • CMenuItem – menu item.
  • CSeparateLine – separation line.
  • CContextMenu – context menu.

Create the MenuBar.mqh file in the Controls folder located in the directory containing the files of all elements. In this file, include the file containing the base class, file with the form class and files of all compound elements that will constitute it:

//|                                                      MenuBar.mqh |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                     |
#include "Element.mqh"
#include "Window.mqh"
#include "MenuItem.mqh"
#include "ContextMenu.mqh"

The basic objects of the main menu are the background and menu items. Context menus will be attached to the items of the main menu via pointers.

Fig. 1. Basic pats of the main menu.

Fig. 1. Basic pats of the main menu.

Author: Anatoli Kazharski

To add comments, please log in or register