Gallery of UIs written in MQL - page 66

 

12. Programmatically obtaining/setting the value boundaries of the slider and the field with buttons (_V_MIN, _V_MAX, _V_STEP, _DIGITS).

1. Let's open a window with elements with the above parameters:

int _OnInit()
  {
   //------------------------------------------------
   //Open the window "Settings example 1".
   //------------------------------------------------
   w_6_Settings_example_1();
   //------------------------------------------------


2. Let's write the values of _V_MIN, _V_MAX, _V_STEP, _DIGITS and output them to the log:

   //------------------------------------------------
   //Get parameter properties, such as: 
   //_V_MIN, _V_MAX, _V_STEP, _DIGITS
   //------------------------------------------------
   int Min_value = w6_i_p3_H_SLIDER_Roll_the_value(get_i,p3_V_MIN);
   int Max_value = w6_i_p3_H_SLIDER_Roll_the_value(get_i,p3_V_MAX);
   int Step      = w6_i_p3_H_SLIDER_Roll_the_value(get_i,p3_V_STEP);
   int digits    = w6_i_p3_H_SLIDER_Roll_the_value(get_i,p3_DIGITS);
   //------------------------------------------------
   //Print the results:
   //------------------------------------------------
   Print("Min_value:  ",Min_value,"  Max_value:  ",Max_value,"  Step:  ",Step,"  digits:  ",digits);
   //------------------------------------------------

Result: the values of the slider parameter properties are logged.


//---------------------------------------------------------------------------------------------------------------------------------------


3. Let's repeat the operation with the field with buttons. Unlike the slider, the field has other number boundaries and its value type is double.

   //------------------------------------------------
   //Get parameter properties, such as: 
   //_V_MIN, _V_MAX, _V_STEP, _DIGITS
   //------------------------------------------------
   double _Min_value  =  w6_d_p5_S_EDIT_Spin_the_value(get_d,p5_V_MIN);
   double _Max_value  =  w6_d_p5_S_EDIT_Spin_the_value(get_d,p5_V_MAX);
   double _Step       =  w6_d_p5_S_EDIT_Spin_the_value(get_d,p5_V_STEP);
   double _digits     =  w6_d_p5_S_EDIT_Spin_the_value(get_d,p5_DIGITS);
   //------------------------------------------------
   Print("Min_value:  ",_Min_value,"  Max_value:  ",_Max_value,"  Step:  ",_Step,"  digits:  ",_digits);
   //------------------------------------------------ 

Result: thevalues of the parameter properties of the field with buttons are displayed in the log.


//---------------------------------------------------------------------------------------------------------------------------------------


4. Set other boundaries of the slider range (tested for the first time, the result is unknown).

   //------------------------------------------------
   //Set parameter properties, such as: 
   //_V_MIN, _V_MAX, _V_STEP.
   //------------------------------------------------
   Min_value = -100;
   Max_value = 100;
   Step      = 1;
   //-----------------
   w6_i_p3_H_SLIDER_Roll_the_value(Min_value, p3_V_MIN);
   w6_i_p3_H_SLIDER_Roll_the_value(Max_value, p3_V_MAX);
   w6_i_p3_H_SLIDER_Roll_the_value(Step,      p3_V_STEP);
   //------------------------------------------------

Result: *found aproblem with the range in negative numbers (fix in the next version).




Let's check with positive range bounds:

   //------------------------------------------------
   //Set parameter properties, such as: 
   //_V_MIN, _V_MAX, _V_STEP.
   //------------------------------------------------
   Min_value = 0;
   Max_value = 1000;
   Step      = 1;
   //-----------------
   w6_i_p3_H_SLIDER_Roll_the_value(Min_value, p3_V_MIN);
   w6_i_p3_H_SLIDER_Roll_the_value(Max_value, p3_V_MAX);
   w6_i_p3_H_SLIDER_Roll_the_value(Step,      p3_V_STEP);
   //------------------------------------------------


Result: range bounds successfully changed.


Main point: The range of the slider can be changed using its function.

**Important:You cannot retroactively change the parameter value type from int to double or vice versa.

//-------------------------------------------------------------------------------------------------


Let's perform a similar experiment with the input field:

   //------------------------------------------------
   //Set NEW parameter properties, such as: 
   //_V_MIN, _V_MAX, _V_STEP, _DIGITS
   //------------------------------------------------
   double _Min_value  = -100.0;
   double _Max_value  =  100.0;
   double _Step       =  2.5;
   //-----------------
   //Set another default value---
   w6_d_p5_S_EDIT_Spin_the_value(50.5);
   //-----------------
   w6_d_p5_S_EDIT_Spin_the_value(_Min_value,p5_V_MIN);
   w6_d_p5_S_EDIT_Spin_the_value(_Max_value,p5_V_MAX);
   w6_d_p5_S_EDIT_Spin_the_value(_Step     ,p5_V_STEP);
   //------------------------------------------------

Result: It works as intended. The field with buttons accepts the specified range and step. If the range is exceeded, it reports an error to the log.

//--------------------------------------------------------------------------------------------------


5. Finally, let's set the value_DIGITS to the field with buttons (the slider won't work because its parameter type is int):

  • Let's set the step value with four digits after the full stop.
  • The digits variable is set to 4 (four decimal places).

       //------------------------------------------------
       //Set parameter properties, such as: 
       //_V_MIN, _V_MAX, _V_STEP, _DIGITS
       //------------------------------------------------
       double _Min_value  = -100.0;
       double _Max_value  =  100.0;
       double _Step       =  2.5567;
              digits      =  4;
       //-----------------
       //Set another default value---
       w6_d_p5_S_EDIT_Spin_the_value(50.5);
       //-----------------
       w6_d_p5_S_EDIT_Spin_the_value(_Min_value,p5_V_MIN);
       w6_d_p5_S_EDIT_Spin_the_value(_Max_value,p5_V_MAX);
       w6_d_p5_S_EDIT_Spin_the_value(_Step     ,p5_V_STEP);
     
       //Set the new number of digits:
       w6_d_p5_S_EDIT_Spin_the_value(digits    ,p5_DIGITS);
       //------------------------------------------------


    Result:

    • At first, there were three digits after the decimal point (the original number before the software change).


    • Then, the software call increased the precision to four digits:


    • Next, to 7 digits:
    //Setting 7 digits after the decimal point:
    
    w6_d_p5_S_EDIT_Spin_the_value(7,p5_DIGITS);



    Results:

    • The ability to programmatically reset the original number range boundaries of the button field as well as the slider is available.
    • It is possible to programmatically change the initial precision of the double value by setting a different number of decimal places.
    • The slider has a problem with calculating values within the boundaries of negative numbers (will be fixed).
    • The original type of the element parameter cannot be reset.

    This concludes this topic.

    Графические интерфейсы VI: Элементы "Слайдер" и "Двухсторонний слайдер" (Глава 2)
    Графические интерфейсы VI: Элементы "Слайдер" и "Двухсторонний слайдер" (Глава 2)
    • www.mql5.com
    В предыдущей статье разрабатываемая библиотека была пополнена сразу четырьмя довольно часто используемыми в графических интерфейсах элементами управления: «чекбокс», «поле ввода», «поле ввода с чекбоксом» и «комбобокс с чекбоксом». Вторая глава шестой части серии будет посвящена таким элементам управления, как слайдер и двухсторонний слайдер.
     

    13. Querying the state of elements _GET_STATE.

    Often there are situations when it is necessary to programmatically get the state of one or another element of the interface. To solve this problem the identifier _GET_STATE is created.

    //--------------------------------------------------------------------------------------------------------------------

    *Important:On the request_GET_STATE, function returns the index of the current state of the element.

    //--------------------------------------------------------------------------------------------------------------------

    The image below shows the list of element states.

    1. state identifiers :

    (*in thenext release, the prefix v_ will be replaced by the prefix s_)


    Indices output to the log:

      v_NEUTRAL_STATE           15
      //-----------------------------
      v_ACTIVATED_STATE         62
      //-----------------------------
      v_NEUTRAL_BLOCKED         64
      //-----------------------------
      v_ACTIVATED_BLOCKED       65   
      //----------------------------- 
      v_NEUTRAL_HIGHLIGHTED     66  
      //-----------------------------
      v_ACTIVATED_HIGHLIGHTED   67


    Let's test querying and retrieving element states:

    1. Open the window and get the initial state of the "Start" button:


    int _OnInit()
      {
       //------------------------------------------------
       //Open the window "Settings example 1".
       //------------------------------------------------
       w_6_Settings_example_1();
       //------------------------------------------------
       //Get state of button "Start":
       //------------------------------------------------
       int Button_state = w6_i_p1_BUTTON_Start(get_i,p1_GET_STATE);
       //------------------------------------------------
       //Print out:
       //------------------------------------------------
       Print("Button state:  ",Button_state);
       //------------------------------------------------


    Result: the value 15 corresponding to the state v_NEUTRAL_STATE is obtained .



    2. Let's log the states of the button on press and release:

    To do this:

    • Let's find the button in the API file.
    • Write a _GET_STATE request for both cases - pressed and released.
    case Settings_example_1___Start:
    
                   //------------------------------------------------------------------------------------------------------
                   //What to do when the button is pressed or released?
                   //------------------------------------------------------------------------------------------------------
                   switch((int)action)
                   {
                    //------------------------------------------------------------------------
                    case pressed: 
                                   {
                                    //Get button's state when it pressed:
                                    int Button_state =  w6_i_p1_BUTTON_Start(get_i,p1_GET_STATE);
                                    
                                    //Print out the result:
                                    Print("Button state:  ",Button_state);
                                   }
                    break;
                    //------------------------------------------------------------------------
                    case released: 
                                   {
                                    //Get button's state when it released:
                                    int Button_state =  w6_i_p1_BUTTON_Start(get_i,p1_GET_STATE);
                                    
                                    //Print out the result:
                                    Print("Button state:  ",Button_state);
                                   }
                    break;
                    //------------------------------------------------------------------------
                   }
                   //------------------------------------------------------------------------------------------------------
                   //Your comment:
                   //------------------------------------------------------------------------------------------------------
                   break;
    


    Result: on the pressed/released event, the current state index is printed to the log.

    Reminder:

    15 = v_NEUTRAL_STATE
    
    62 = v_ACTIVATED_STATE

    //----------------------------------------------------------------------------------------------------------------


    3. Let's repeat the query with the checkbox.



    1. Let's get the state of the checkbox on the event of window opening:

       //------------------------------------------------
       //Open the window "Settings example 1".
       //------------------------------------------------
       w_6_Settings_example_1();
       //------------------------------------------------
       
       //Get the state of the checkbox when it checked:
       int Checkbox_state = w6_i_p7_CHECKBOX_Set_an_option(get_i,p7_GET_STATE);
       
       //Print out the result:
       Print("Checkbox state:  ",Checkbox_state);
       //------------------------------------------------

    Result: the value 15 is obtained, corresponding to the neutral state v_NEUTRAL_STATE (where the checkbox is).




    2. Next, let's query the states of the checkbox on the press and release event.

    To do this:

    • Let's find the"Set an option" checkbox in the API file.
    • Let's write the _GET_STATE query for both cases - checked and unchecked.
    case Settings_example_1___Set_an_option:
      
                   //------------------------------------------------------------------------------------------------------
                   //What to do when the checkbox is checked or unchecked? 
                   //------------------------------------------------------------------------------------------------------
                    case checked: 
                                   {
                                    //Get checkbox state when it checked:
                                    int Checkbox_state = w6_i_p7_CHECKBOX_Set_an_option(get_i,p7_GET_STATE);
                                    
                                    //Print out the result:
                                    Print("Checkbox state:  ",Checkbox_state);
                                   }
                    break;
                    //------------------------------------------------------------------------
                    case unchecked: 
                                   {
                                    //Get checkbox state when it unchecked:
                                    int Checkbox_state = w6_i_p7_CHECKBOX_Set_an_option(get_i,p7_GET_STATE);
                                    
                                    //Print out the result:
                                    Print("Checkbox state:  ",Checkbox_state);
                                   }
                    break;
                   //------------------------------------------------------------------------------------------------------
                   //Your comment:
                   //------------------------------------------------------------------------------------------------------
                   break;


    Result: we get values 66 (v_NEUTRAL_HIGHLIGHTED) and 67 (v_ACTIVATED_HIGHLIGHTED), which means highlighted neutral and highlighted pressed state.

    //-----------------------------------------------------------------------------------------------

    This concludes the first part of the topic.

    In the second part, we will return the states of the D_LIST drop-down list, the H_SLIDER slider, and the S_EDIT and EDIT input fields.

     

    13. Status request _GET_STATE.

    Part 2: Getting the states of D_LIST, H_SLIDER, EDIT, S_EDIT elements .

    In the last part, we looked at programmatically returning the states of the BUTTON button and CHECKBOX checkbox. The _GET_STATE query was used and the list of state names returned by the functions was shown. There are six names in all, where each begins with the prefix v_. (An abbreviation of value, which will be replaced by s_ - an abbreviation of state).

    Recall the state indices:

      v_NEUTRAL_STATE           15
      //-----------------------------
      v_ACTIVATED_STATE         62
      //-----------------------------
      v_NEUTRAL_BLOCKED         64
      //-----------------------------
      v_ACTIVATED_BLOCKED       65   
      //----------------------------- 
      v_NEUTRAL_HIGHLIGHTED     66  
      //-----------------------------
      v_ACTIVATED_HIGHLIGHTED   67

    In this case, the specific index numbers are not important. When the user needs to put a particular state into a condition, he uses an identifier.

    Example 1:

    //Getting state of the first element:
    int Button_state = w6_i_p1_BUTTON_Start(get_i,p1_GET_STATE);
    
    //Getting state of the second element:
    int Checkbox_state = w6_i_p7_CHECKBOX_Set_an_option(get_i,p7_GET_STATE);
    
    
    //Setting conditions for both elements when they're simultaneously ON:
    if(Button_state == v_ACTIVATED_STATE)
      { 
       //Is the checkbox was already on:
        if(Checkbox_state == v_ACTIVATED_STATE)
          {
           Function_1();
          }
        //If the checkbox was the last pressed element and still highlighted:
        if(Checkbox_state == v_ACTIVATED_HIGHLIGHTED)
          {
           Function_2();
          }
      }


    Example 2:

    //Getting state of the first element:
    int Button_state = w6_i_p1_BUTTON_Start(get_i,p1_GET_STATE);
    
    //Getting state of the second element:
    int Checkbox_state = w6_i_p7_CHECKBOX_Set_an_option(get_i,p7_GET_STATE);
    
    
    //Setting conditions for one element being ON, while the other is OFF:
    if(Button_state == v_ACTIVATED_STATE)
      { 
       //If the checkbox was already off:
        if(Checkbox_state == v_NEUTRAL_STATE)
          {
           Function_A();
          }
        //If the checkbox was just turned off and still highlighted:
        if(Checkbox_state == v_NEUTRAL_HIGHLIGHTED)
          {
           Function_B();
          }
      }

    //-----------------------------------------------------------------------------------------------------------------

    *Very important:

    Let me explain the essential difference between v_NEUTRAL_STATE and v_NEUTRAL_HIGHLIGHTED states , and between v_ACTIVATED_STATE and v_ACTIVATED_HIGHLIGHTED:

    v_NEUTRAL_STATE - это нейтральное состояние в котором элемент находится неопределенное время.
    
    v_NEUTRAL_HIGHLIGHTED - это нейтральное состояние в которое элемент перешел ТОЛЬКО ЧТО, после отжатия пользователя. Поэтому элемент подсвечен - HIGHLIGHTED. 

    the same applies to the activated state:

    v_ACTIVATED_STATE - это активированное состояние в котором элемент находится неопределенное время.
    
    v_ACTIVATED_HIGHLIGHTED - это активированное состояние в которое элемент перешел ТОЛЬКО ЧТО, после нажатия пользователя. Поэтому элемент подсвечен - HIGHLIGHTED. 

    This difference makes a big difference.

    Currently, the button and some other elements, only return v_NEUTRAL_STATE and v_ACTIVATED_STATE, and do not return HIGHLIGHTED states like a checkbox. This means that the user has no way of knowing if items were clicked/unclicked just now, or when, an indefinite time ago. However, the user can catch the moment they were pressed in the API file. Yes, but this feature is not yet available in the rest of the programme. In the next version, HIGHLIGHTED state return will be added to all interactive elements. This way, from anywhere in the programme, the user will be able to know whether an element has just been pressed/unpressed, or has been in its state for a long time.

    //----------------------------------------------------------------------------------------------------------


    Let's move on to the practical part:

    • Let's open two windows with elements D_LIST, H_SLIDER, EDIT and S_EDIT.
    • Let's return the states of the elements immediately after opening.

    1. Open the windows:

    int _OnInit()
      {
       //------------------------------------------------
       //Open the windows "Settings example 1" and "Settings example 2".
       //------------------------------------------------
       w_6_Settings_example_1();
       w_7_Settings_example_2();
       //------------------------------------------------


    2. Let's get the states of the elements:

       //------------------------------------------------
       //Get the states of the elements S_EDIT, H_SLIDER, EDIT and D_LIST
       //------------------------------------------------
       //1. State index is type int, S_EDIT's function is double. Convert the types.
       int S_edit_state   = (int)w6_d_p5_S_EDIT_Spin_the_value(get_d,p5_GET_STATE); 
       
       //2. Getting the slider's state. 
       int H_slider_state =      w6_i_p3_H_SLIDER_Roll_the_value(get_i,p3_GET_STATE);
       
       //3.State index is type int, EDIT's function is string. Convert the types. 
       int Edit_state     = (int)w7_s_p4_EDIT_Comment_3(get_s,p4_GET_STATE);
       
       //State index is type int, D_LIST's function is string. Convert the types.
       int D_list_state   = (int)w7_s_p6_D_LIST_D_LIST_1(get_s,p6_GET_STATE);
       //------------------------------------------------
       
       //Print out the results:
       Print("S_edit_state   = ",S_edit_state);
       Print("H_slider_state = ",H_slider_state);
       Print("Edit_state     = ",Edit_state);
       Print("D_list_state   = ",D_list_state);
       //------------------------------------------------


    Result: all elements of the D_LISTcnome have state index 15 (neutral state v_NEUTRAL_STATE). D_LIST returned an error (-1).


    Reason: the return of states of this element is not specified in the central function. Technical defect.It will be corrected in the next version.

    Since the D_LIST function does not return the state index yet , let's focus on three items whose states were successfully received: EDIT , S_EDIT and H_SLIDER.

    What to check:

    • What indices the function returns when the elements are locked and clicked.
    • Whether the given elements have aHIGHLIGHTED ( highlighted) state. In other words, whether it is possible to know whether the element has just been clicked or not.

    We have just verified that the EDIT, S_EDIT and H_SLIDER element functions return an index of the neutral state when the window is opened. It remains to check the other states. Since these types of elements, in theory, can only be in neutral, locked and highlighted states (unlike buttons and checkboxes, which have more states), we have to check the following two possible states: locked and highlighted. There is also a group of"under cursor" states, which I don't want to add yet to avoid confusion. In the next versions I will create a special prefix that opens an individual list of possible states of each type of element. This will make programmatic work easier.

    How we will check the return of the blocked and highlighted statesEDIT, S_EDIT and H_SLIDER:

    • Let's find the "Set an option" checkbox in the API file.
    • Let's write locking/unlocking of EDIT, S_EDIT and H_SLIDER elements inside its case and print() the states of the elements there.
    • Let's find EDIT, S_EDIT and H_SLIDER elements in the API file.
    • Write a state return on the event of entering a value into these elements.
    • Let's print the result obtained via Print().
    //-------------------------------------------------------------------------------------------------

    1. Find the "Set an option" checkbox in the API file and write the locking/unlocking ofEDIT, S_EDIT and H_SLIDER elementsinside its case.Then, output the states via Print().

    case Settings_example_1___Set_an_option:
      
                switch((int)action)
                   {
                   //------------------------------------------------------------------------------------------------------
                   //What to do when the checkbox is checked or unchecked? 
                   //------------------------------------------------------------------------------------------------------
                    case checked: 
                                   {
                                    //-----------------------------------------------
                                    //Locking EDIT:
                                    w7_s_p4_EDIT_Comment_1(p4_LOCK);
                                    
                                    //Locking H_SLIDER:
                                    w6_i_p3_H_SLIDER_Roll_the_value(p3_LOCK);
                                    
                                    //Locking S_EDIT:
                                    w6_d_p5_S_EDIT_Spin_the_value(p5_LOCK); 
                                    
                                    //-----------------------------------------------
                                    //Getting state of EDIT:
                                    int EDIT_state =  (int)w7_s_p4_EDIT_Comment_1(get_s, p4_GET_STATE);
    
                                    //Getting state of H_SLIDER:
                                    int H_SLIDER_state = w6_i_p3_H_SLIDER_Roll_the_value(get_i,p3_GET_STATE); 
    
                                    //Getting state of S_EDIT:
                                    int S_EDIT_state = (int)w6_d_p5_S_EDIT_Spin_the_value(get_d, p5_GET_STATE); 
                                    //-----------------------------------------------
                                    
                                    //Printing results:
                                    Print("EDIT_state      = ",EDIT_state);
                                    Print("H_SLIDER_state  = ",H_SLIDER_state);
                                    Print("S_EDIT_state    = ",S_EDIT_state);
                                    //-----------------------------------------------
                                   }
                    break;
                    //------------------------------------------------------------------------
                    case unchecked: 
                                   {
                                    //-----------------------------------------------
                                    //Unlocking the element EDIT:
                                    w7_s_p4_EDIT_Comment_1(p4_UNLOCK);
                                    
                                    //Unlocking H_SLIDER:
                                    w6_i_p3_H_SLIDER_Roll_the_value(p3_UNLOCK);
                                    
                                    //Unlocking S_EDIT:
                                    w6_d_p5_S_EDIT_Spin_the_value(p5_UNLOCK);
                                    
                                    //-----------------------------------------------
                                    //Getting state of EDIT:
                                    int EDIT_state =  (int)w7_s_p4_EDIT_Comment_1(get_s, p4_GET_STATE);
    
                                    //Getting state of H_SLIDER:
                                    int H_SLIDER_state = w6_i_p3_H_SLIDER_Roll_the_value(get_i,p3_GET_STATE); 
    
                                    //Getting state of S_EDIT:
                                    int S_EDIT_state = (int)w6_d_p5_S_EDIT_Spin_the_value(get_d, p5_GET_STATE); 
                                    //-----------------------------------------------
                                    
                                    //Printing results:
                                    Print("EDIT_state      = ",EDIT_state);
                                    Print("H_SLIDER_state  = ",H_SLIDER_state);
                                    Print("S_EDIT_state    = ",S_EDIT_state);
                                    //-----------------------------------------------
                                   }
                    break;
                   } 
                   //------------------------------------------------------------------------------------------------------
                   //Your comment:
                   //------------------------------------------------------------------------------------------------------
                   break;


    Result:

    • On the event of clicking the checkbox, the element functions return index 64, which corresponds to the v_NEUTRAL_BLOCKED (neutral-locked) state.
    • On the event of unchecking the checkbox, the element functions return an index of 15, which corresponds to the state v_NEUTRAL_STATE (neutral state).

    //--------------------------------------------------------------------------------------------------

     

    2. Second task:

    • Find theEDIT, S_EDIT, H_SLIDER elements in the API file and prescribe getting the state when a value is entered to see if their functions return a HIGHLIGHTED ( highlighted) index.

    Getting started:

    case Settings_example_2___Comment_1:
      
                   //------------------------------------------------------------------------------------------------------
                   //What to do when the text is entered?
                   //------------------------------------------------------------------------------------------------------
                   {
                    //Getting state of EDIT:
                    int EDIT_state =  (int)w7_s_p4_EDIT_Comment_1(get_s, p4_GET_STATE);
                                    
                    //Printing the results:
                    Print("EDIT_state      = ",EDIT_state);
                   } 
                   //------------------------------------------------------------------------------------------------------
                   //Your comment:
                   //------------------------------------------------------------------------------------------------------
                   break;
    case Settings_example_1___Roll_the_value:
      
                   //------------------------------------------------------------------------------------------------------
                   //What to do when the slider's handle is moved?
                   //------------------------------------------------------------------------------------------------------
                   //Min value:  0  |   Max value:  100  |   V_step:  1  |   Default value:  75  |  Digits: Integer value
                   //------------------------------------------------------------------------------------------------------
                   {
                    //Getting state of H_SLIDER:
                    int H_SLIDER_state = w6_i_p3_H_SLIDER_Roll_the_value(get_i,p3_GET_STATE); 
                                    
                    //Printing results:
                    Print("H_SLIDER_state  = ",H_SLIDER_state);
                   }           
                   //------------------------------------------------------------------------------------------------------
                   //Your comment:
                   //------------------------------------------------------------------------------------------------------
                   break;
    case Settings_example_1___Spin_the_value:
      
                   //------------------------------------------------------------------------------------------------------
                   //What to do when the value is set?
                   //------------------------------------------------------------------------------------------------------
                   //Min value:  NOT SET  |   Max value:  NOT SET  |   V_step:  1.7  |   Default value:  468.99  |  Digits: 3
                   //------------------------------------------------------------------------------------------------------
                   {
                    //Getting state of S_EDIT:
                    int S_EDIT_state = (int)w6_d_p5_S_EDIT_Spin_the_value(get_d, p5_GET_STATE); 
                                    
                    //Printing results:
                    Print("S_EDIT_state    = ",S_EDIT_state); 
                   }
                   //------------------------------------------------------------------------------------------------------
                   //Your comment:
                   //------------------------------------------------------------------------------------------------------
                   break;

    Result:

    • EDIT: On a user interaction event, returns a state index of 67, which meansv_ACTIVATED_HIGHLIGHTED ( activated, highlighted).

    • S_EDIT: On a user interaction event, returns a status index of 67, meaningv_ACTIVATED_HIGHLIGHTED ( activated, highlighted).
    • H_SLIDER: On user interaction event, alternately returns indexes 66 and 67, which meansv_NEUTRAL_HIGHLIGHTED ( neutral, illuminated) andv_ACTIVATED_HIGHLIGHTED (activated, illuminated).Bug. Correction in the next version.



    //-----------------------------------------------------------------------------------------------------

    Results:

    In general, the results can be evaluated as satisfactory. Elements return indices of neutral and locked states as intended. However, there are some shortcomings:

    • The D_LIST element function does not return any states.
    • The H_SLIDER element function alternately returns indices ofv_NEUTRAL_HIGHLIGHTED andv_ACTIVATED_HIGHLIGHTED states instead of one index 67 - v_ACTIVATED_HIGHLIGHTED(activated, illuminated).

    Conclusions:

    • Need to fix the deficiencies.
    • It is necessary to create a list of intellisense called by a special prefixs_ so that the user could know which types of elements have which states and easily use them in the code.

    Potentially, it is possible to add new element states. For example, Neutral pointed and Activated pointed ( neutral under the cursor and activated under the cursor), but there is a question of practicality and the real need of the user to have these features. Until such requirements are not received, I will not add new states.

    That's the end of this topic.


    Further, to the following topics.

     

    I've spent the last week researching how to write an interface using WinForm and embed it into MT5 charts. Today I finally realised it.

     
    Uploading a video is easier than uploading a gif and the file is smaller.
     

    A general list of topics to consider:

    1. Orientation in the list of intellisense and selecting the function of the right window.

    2. Opening and closing windows programmatically.

    3. Opening a list of programmatically available window elements.

    4. Opening a list of individual element properties.

    5. Parsing the name of the element and window wrapper function.

    6. Returning the value of an element parameter to a variable of its type.

    7. Setting values to element parameters of different types.

    8. Returning, changing and forwarding values between parameters of different elements. Consider different types of elements and values, and test forwarding between different types of elements in different windows.

    9. Return previous value (_V_LAST). When and for what cases the last value is required (not to be confused with the current value).

    10. Test for setting ON, OFF, LOCK_ON, LOCK_OFF, LOCK, UNLOCK states for different element types.

    11. test of binding and synchronisation of changing values of elements: e.g. input field with buttons and slider. So that when the value of one element (manual or software) changes, the value in the second element changes accordingly.

    12. Testing of software obtaining/setting of range boundaries of the slider and the field with buttons (properties _V_MIN, _V_MAX, _V_STEP, _DIGITS).

    13. Testing the operation of the item status query (_GET_STATE).

    14. Linking text and border colours to spaced value boundaries.

    15. Orientation in the API file.

    16.Implementation of simple program logic of message and warning windows appearance.

    //------------------------------------------

    The topics that have been considered are highlighted in yellow.

    For the current moment there are some left to be considered:

    14. Linking text and frame colours to spaced value boundaries.

    15. Orientation in the API file.

    16.Implementation of simple program logic of message and warning windows appearance.

    //------------------------------------------

    I suggest linking topic 14 with topic 16. Going beyond the set limits of parameter values will first cause signals in the form of changing the colour of parts of elements (text, base, frame, stripe, etc.), then opening a dialogue window, and then a warning window. At the same time, the warning window will block changes to values in elements until it is manually closed by the user.


    Also, I'd like to add a theme to the list:

    17. cancelling entered settings when the user clicks on the "Cancel" button.

    A long time ago, the technology of cancelling user settings by clicking the "Cancel" button was developed and to some extent tested. At the moment, it is not known how much the former functionality works. Therefore, a test is necessary.


    As a result of the overlap of topics, the order of review will be as follows:

    14. Implementing staggered parameter boundary protection:

    • Writing logic to control settings within preset boundaries and creating a warning system.
    • Warning 1: the user receives a signal in the form of a change in the colour of parts of the elements.(Let's link the colour of text, bases, frames and slider bar to the value boundaries.)
    • Warning 2: opening a dialogue box with a risk notification and a suggestion to go back to the original settings. ( Let's test the actual ability to revert to the previous settings when clicking on the "Cancel" button. )
    • Warning 3: opening a warning window blocking further changes to the settings and notifying the user of the disclaimer, requiring manual user confirmation. ( Let's test the blocking of windows when the warning window appears. )


    15. Let's consider the new API file printout in detail.

    //----------------------------------------------------------------------------------------------------


    Next, I will collect all the bugs or defects found and make a list of tasks for the next release.

    After the next release with fixes and additions, I will focus on the tables, in which I see one of the main directions of further development of the engine.

    Документация по MQL5: Основы языка / Операторы / Оператор возврата return
    Документация по MQL5: Основы языка / Операторы / Оператор возврата return
    • www.mql5.com
    Оператор return прекращает выполнение текущей функции и возвращает управление вызвавшей программе. Результат вычисления выражения возвращается...
     
    hini #:

    I've spent the last week learning how to write an interface using WinForm and build it into MT5 charts. Today I finally figured out how to do it.


    And how will you make the interface communicate with your programming code?

     
    Реter Konow #:

    And how will you establish a connection between the interface and your programming code?

    A few more questions:

    • how many forms (windows) can you "build" into MT5 charts?
    • How will you translate data into tables?
    • Can you use ready-made templates when creating windows?
    • Can you create your own taskbar and context menu inside MT5?
    • How will you implement software return/set properties of items? By polling the DLL from the timer function?
    Tell me more about the solution you found. This is very interesting. :)
     

    In principle, everyone can use the tool they are comfortable with. I am comfortable with my interface and that is why I am developing it. In other words, I am going to use it in my own algorithmic trading. Publishing solutions on the forum adds motivation. If my interface turns out to be useful to someone - fine, if not - it won't hurt me.

    In the interface I see a powerful tool, which, combined with the algorithmic capabilities of MT5, will allow me to scale the results of correct trading. Yes, in this long way, I am "going to market". It takes years, but in any case, it takes me time to develop intellectually. There's no point in trading the market with money but no brains, is there?

    The decision to use WinForms, or something similar, is in my opinion incomplete in nature. It leads to technical detachment from MT5 and building an independent multi-window Windows application. At the first stage it will be connected to the platform by a data channel like an umbilical cord. The user will wiggle with DLL polls and may even be successful. If desired, he will be able to create a context menu, and use some templates for quick creation of windows..... But in the end..., he will work in two or three IDEs at once, and in different programming languages. So how is it better? And more importantly - how is it easier?

    Besides, having a multi-window Windows application, the user can directly connect it to the API of another trading platform. So it will be easier for him than working through a timer. And the market should be mentioned. His product will not be allowed there. In general, to each his own.