Let's
continue exploring various controls and this time turn our attention to
scrollbar. Just like in the previous article entitled "MQL5 Cookbook:
Indicator Subwindow Controls - Buttons", all operations will be
performed in the indicator subwindow. Take a moment to read the above
mentioned article as it provides a detailed description of working with
events in the OnChartEvent() function, while this point will only be
casually touched upon in this article. For illustrative purposes, this
time around we will create a vertical scrollbar for a large list of all
financial instrument properties that can be obtained using MQL5
resources.
In the previous articles on MQL5 programming we used the graphical object OBJ_LABEL
(Text Label) to create lists. In this article, we will use a canvas to
display text. The convenience of such approach lies in that instead of a
great number of OBJ_LABEL objects, we will only use one - OBJ_BITMAP_LABEL (Bitmap Label). You can draw any interface elements on a canvas but this time we will limit ourselves to text only.
The scrollbar will be very simple. It usually has arrow buttons but
they will not be features in our case. The scrollbar will only consist
of the background and scroll box. The scroll box will change its color
when the cursor goes over it. When clicked, it will also change color
suggesting to the user that the scroll box is now selected and can be
dragged. In creating scrolling objects, we will use graphical objects of
the OBJ_RECTANGLE_LABEL (Rectangle Label) type.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
New article MQL5 Cookbook: Indicator Subwindow Controls - Scrollbar has been published at mql5.com:
Let's continue exploring various controls and this time turn our attention to scrollbar. Just like in the previous article entitled "MQL5 Cookbook: Indicator Subwindow Controls - Buttons", all operations will be performed in the indicator subwindow. Take a moment to read the above mentioned article as it provides a detailed description of working with events in the OnChartEvent() function, while this point will only be casually touched upon in this article. For illustrative purposes, this time around we will create a vertical scrollbar for a large list of all financial instrument properties that can be obtained using MQL5 resources.
In the previous articles on MQL5 programming we used the graphical object OBJ_LABEL (Text Label) to create lists. In this article, we will use a canvas to display text. The convenience of such approach lies in that instead of a great number of OBJ_LABEL objects, we will only use one - OBJ_BITMAP_LABEL (Bitmap Label). You can draw any interface elements on a canvas but this time we will limit ourselves to text only.
The scrollbar will be very simple. It usually has arrow buttons but they will not be features in our case. The scrollbar will only consist of the background and scroll box. The scroll box will change its color when the cursor goes over it. When clicked, it will also change color suggesting to the user that the scroll box is now selected and can be dragged. In creating scrolling objects, we will use graphical objects of the OBJ_RECTANGLE_LABEL (Rectangle Label) type.
Author: Anatoli Kazharski