Download MetaTrader 5

New article: Graphical Interfaces II: the Menu Item Element (Chapter 1)

To add comments, please log in or register
MetaQuotes Software Corp.
MetaQuotes Software Corp.  

New article Graphical Interfaces II: the Menu Item Element (Chapter 1) has been published:

In the second part of the series, we will show in detail the development of such interface elements as main menu and context menu. We will also mention drawing elements and create a special class for it. We will discuss in depth such question as managing program events including custom ones.

In the chapters of the first series, we discussed in full the process of developing the main structure of the library for creating graphical interfaces. There, we also created the main element of the interface - a form for controls. The first article: Graphical Interfaces I: Preparation of the Library Structure (Chapter 1) explains in detail what this library is for. A complete list of links to the articles of the first part is at the end of each chapter. There, you can also download a complete version of the library at the current stage of development. The files must be placed in the same directories as they are located in the archive.

The Main Menu of the Program

It is difficult to find a program that does not have the main menu. The MetaTrader terminals also have this interface element (see the screenshot below). Usually, the menu is located in the top left part of the program window and consists of several items. A left mouse click on a menu item brings up a drop-down list with the program options.

Fig. 1. Main menu in the MetaTrader 5 terminal

Fig. 1. Main menu in the MetaTrader 5 terminal

This drop-down list is called a context menu and can contain several types of items. Let us consider each of them in detail:

  • A button item. This is the simplest element in the context menu. Usually, a left click opens a window with extended functionality for setting up a program or a window containing some information. There can also be very simple functions. They change something in the appearance of the program interface after a button item has been clicked on.
  • An item with two states of the checkbox type. This element can be used to activate some process or open (make visible) some part of the program interface. When that happens, this item changes its appearance and shows the application user what state it is in.
  • A group of items. In this group only one item can be enabled. This type of control is called a radio button or a switch. We will call it a radio item in this article.
  • An item for calling a context menu. The context menu which was called from the main program file can have items containing one more context menu. After clicking on such an item, a context menu will appear to the right from it.

Author: Anatoli Kazharski

To add comments, please log in or register