Discussion of article "MQL5 Cookbook: Indicator Subwindow Controls - Scrollbar"

 

New article MQL5 Cookbook: Indicator Subwindow Controls - Scrollbar has been published:

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.

MQL5 Cookbook: Indicator Subwindow Controls - Scrollbar

Author: Anatoli Kazharski

 
Recently i have following all article from Anatoli and i must say he is a great coder. Furthermore he share his knowledge with others that new to MT5 programming language, like me, which i think is a generous move. I hope in future more articles will be publish by Anatoli.
 

Hello 

MetaQuotes:

New article MQL5 Cookbook: Indicator Subwindow Controls - Scrollbar has been published:

Author: Anatoli Kazharski

Hello Anatoli Kazharski

However the topic is so old, but I wanted to thank you for the great and helpful job.

I needed the scrollbar, but I just could find it used in the ListViews, But here I was able to pull out the scrollbar functions and use them. 

I only noticed that however this part logically may always work, but may not be what you meant to write:

//+------------------------------------------------------------------+
//| Changing the color of the scroll box when the cursor hovers over |
//+------------------------------------------------------------------+
void ChangeScrollbarThumbColorOnHover(int x,int y)
  {
//--- If the cursor is within the scroll box area, make the color darker
   if(x>scrollbar_thumb_x1 && x<scrollbar_thumb_x2 && y>scrollbar_thumb_y1 && y<scrollbar_thumb_x2)

      SetScrollbarThumbColor(scrollbar_thumb_color_on_hover);
//--- If the cursor is outside the scroll box boundaries
   else
     {
      //--- If the mouse button is released, set the standard scroll box color
      if(!mouse_button_state)
         SetScrollbarThumbColor(scrollbar_thumb_color);
     }
  }

Again, Thanks for the great job.

Reason: