New article Graphical Interfaces I: Animating the Graphical Interface (Chapter 3) has been published on mql5.com:
This article is the continuation of the first part of the series about graphical interfaces. 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.
In the previous article
of the series, we started to develop a form class for controls. In this
article, we are going to continue developing this class and fill it
with methods for moving the form over the chart area. We will also
integrate this interface component into the core of the library. Also,
we will ensure that the color of a form control changes when the cursor
is hovering over it.
Earlier we considered the implementation of the CElement class, which is base class for all controls. We created the CElement::ChangeObjectColor()
method for changing the object color when hovering the cursor over as
one of its members. This is the time to create a mechanism which will
allow us to use it in our work. Adding such functionality requires a
timer. This is disabled in the settings of the MQL application by
default. It is up to the application developer to decide whether the
timer is to be enabled depending on the set goals.
To enable the timer, the MQL language has two functions with different frequency: EventSetTimer() and EventSetMillisecondTimer().
The first one allows to set an interval no shorter than one second.
This does not suit our purposes as one second is too high an interval
for a control to change its appearance when the cursor is hovered over
it. The change should happen instantly with no delays. We are going to
use the EventSetMillisecondTimer()
function, which supports setting a timer with intervals measured in
milliseconds. According to the MQL reference, a minimal interval that
can be set using this function is 10-16 milliseconds. This is enough to
realize our plan.
Fig. 2. Test for the object reaction to the mouse cursor
Author: Anatoli Kazharski
To add comments, please log in or register