Discussion of article "Graphical Interfaces II: Setting Up the Event Handlers of the Library (Chapter 3)"

 

New article Graphical Interfaces II: Setting Up the Event Handlers of the Library (Chapter 3) has been published:

The previous articles contain the implementation of the classes for creating constituent parts of the main menu. Now, it is time to take a close look at the event handlers in the principle base classes and in the classes of the created controls. We will also pay special attention to managing the state of the chart depending on the location of the mouse cursor.


Private Arrays of the Elements

Let us conduct a little experiment. Left click on one of the context menu items in the area where the mouse cursor will be outside of the form area. We will see that the chart scroll has not been disabled and it can be used when hovering over the control. This is a functional error and it should not be there. We are going to arrange so that no matter what control the mouse cursor is over, the chart scroll and the moving of trading levels mode are disabled at that time. 

First of all, let us add tracking the focus on the element to the context menu handler as shown in the code below. If the context menu is hidden, then there is no need to continue. Follow this approach to save time.

Preliminary Test of Event Handlers

After all changes have been introduced, compile all the files and load the program to the chart for testing. Now, when an independent menu item on the form is clicked on, its context menu will appear if this was hidden before and hide if this was open. Added to that, when a context menu is open, then the background color of the menu item will be fixed, that is will not change again if the mouse cursor is removed from its area as shown in the screenshot below. 

Fig. 1. Test of showing and hiding a context menu.

Fig. 1. Test of showing and hiding a context menu.

Author: Anatoli Kazharski

 

It's really good work.

In the constructor of CContextMenu I added the line

CContextMenu::m_item_y_size=24;

so 'm_item_y_size' has a default value and the TestLibrary compiles pretty.

 
Otto Pauser:

It's really good work.

In the constructor of CContextMenu I added the line

so 'm_item_y_size' has a default value and the TestLibrary compiles pretty.

Thank you for message. All corrections will be made in the next part of this series.
Reason: