Discussion of article "Graphical Interfaces VI: the Checkbox Control, the Edit Control and their Mixed Types (Chapter 1)"
But "winking" when reaching extreme values will not work in indicators - Sleep() ...
Anatoly, write down one more request for improvement: delay should be organised through a timer, especially since you already have almost everything for it.
Anatoly, the library created by you is in a high degree of readiness and I decided to try to create a small project for myself using it. I am writing in this topic so that it would be clear to which element the question refers. For the input field (SpinEdit) it is necessary to enter values with an accuracy of two tenths. I set the corresponding properties (StepValue and StepDigits) in the procedure of field creation (see the code below):
... m_spin_edit_Depo.MaxValue(10000000); m_spin_edit_Depo.MinValue(0); m_spin_edit_Depo.StepValue(0,01); m_spin_edit_Depo.SetDigits(2); m_spin_edit_Depo.SetValue(v); ...
And after compilation I got an error: 'StepValue' - none of the overloads can be applied to the function call.
Logically, if the number of characters for a value is less than 1, then the step value increment can also be less than one. At the same time, in the code of the class, the check of the entered value goes only for non-negativity.
...
//--- Шаг значения
double StepValue(void) const { return(m_step_value); }
void StepValue(const double value) { m_step_value=(value<=0)? 1 : value; }
...
The question is that it is not clear to me where the error comes from.
Then I have a question or a wish. What if we don't need to control the minimum/maximum value and it is limited only by the size of the variable of double type used to store it? As I understood from the code, setting the minimum/maximum values is mandatory. Is it possible to add my wish to the list of improvements? I.e. If the minimum/maximum values for a field are not specified, the control of entered values is performed only on its entering the range of the variable of double type.
And after compilation I got the following error: 'StepValue' - none of the overloads can be applied to the function call.
...
The question is that it is not clear to me where the error comes from.
You have a typo. Use a dot "." as a separator. :
m_spin_edit_Depo.StepValue(0. 01);//---
Next, I have a question or a wish. What if I don't need to control the minimum/maximum value and it is limited only by the size of the variable of double typeused for its storage ? As I understood from the code, setting the minimum/maximum values is mandatory. Is it possible to add my wish to the list of improvements? I.e. If the minimum/maximum values for a field are not specified, the control of entered values is performed only on its entering the range of the variable of double type.
You can set the maximum and minimum forcibly for now. Like this:
m_spin_edit_Depo.MaxValue(DBL_MAX); m_spin_edit_Depo.MinValue(-DBL_MAX);
You have a typo. Use a full stop "." as a separator. :
//---
You can force the maximum and minimum for now. There you go:
New article Graphical Interfaces VI: the Checkbox Control, the Edit Control and their Mixed Types (Chapter 1) has been published:
Author: Anatoli Kazharski
Hello sir i am interesting on your Article but i stil newbie about GUI and mql,
can you please tell me how to get value of Spin edit so it can be read to the EA.
Regards
Hello sir i am interesting on your Article but i stil newbie about GUI and mql,
can you please tell me how to get value of Spin edit so it can be read to the EA.
Regards
For example, from an article in CProgram::OnEvent() event handler:
void CProgram::OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam) { //--- Событие нажатия на текстовой метке if(id==CHARTEVENT_CUSTOM+ON_CLICK_LABEL) { ::Print(__FUNCTION__," > id: ",id,"; lparam: ",lparam,"; dparam: ",dparam,"; sparam: ",sparam); //--- Если нажали на первом чекбоксе if(lparam==m_checkbox1.Id()) { m_checkbox2.CheckBoxState(m_checkbox1.CheckButtonState()); m_spin_edit1.SpinEditState(m_checkbox1.CheckButtonState()); Print("m_spin_edit1.GetValue(): ",m_spin_edit1.GetValue()); } if(lparam==m_checkbox3.Id()) { m_checkboxedit1.CheckBoxEditState(m_checkbox3.CheckButtonState()); Print("m_checkboxedit1.GetValue(): ",m_checkboxedit1.GetValue()); } if(lparam==m_checkbox4.Id()) { m_checkcombobox1.CheckComboBoxState(m_checkbox4.CheckButtonState()); } if(lparam==m_checkbox5.Id()) { m_slider1.SliderState(m_checkbox5.CheckButtonState()); m_dual_slider1.SliderState(m_checkbox5.CheckButtonState()); Print("m_slider1.GetValue(): ",m_slider1.GetValue()); Print("m_dual_slider1.GetLeftValue(): ",m_dual_slider1.GetLeftValue()); Print("m_dual_slider1.GetRightValue(): ",m_dual_slider1.GetRightValue()); } } if(id==CHARTEVENT_CUSTOM+ON_END_EDIT) { ::Print(__FUNCTION__," > id: ",id,"; lparam: ",lparam,"; dparam: ",dparam,"; sparam: ",sparam); if(lparam==m_spin_edit1.Id()) { Print("m_spin_edit1.GetValue(): ",m_spin_edit1.GetValue()); } if(lparam==m_checkboxedit1.Id()) { Print("m_checkboxedit1.GetValue(): ",m_checkboxedit1.GetValue()); } if(lparam==m_slider1.Id()) { Print("m_slider1.GetValue(): ",m_slider1.GetValue()); } if(lparam==m_dual_slider1.Id()) { Print("m_dual_slider1.GetLeftValue(): ",m_dual_slider1.GetLeftValue()); Print("m_dual_slider1.GetRightValue(): ",m_dual_slider1.GetRightValue()); } } if(id==CHARTEVENT_CUSTOM+ON_CLICK_INC || id==CHARTEVENT_CUSTOM+ON_CLICK_DEC) { ::Print(__FUNCTION__," > id: ",id,"; lparam: ",lparam,"; dparam: ",dparam,"; sparam: ",sparam); if(lparam==m_spin_edit1.Id()) { Print("m_spin_edit1.GetValue(): ",m_spin_edit1.GetValue()); } if(lparam==m_checkboxedit1.Id()) { Print("m_checkboxedit1.GetValue(): ",m_checkboxedit1.GetValue()); } } }
For example, from an article in CProgram::OnEvent() event handler:
Regard's
Dear Anatoli Kazharski, thank you so much for this great library!
I kind of love the look & feel of the resulting interfaces.
When starting to adapt Test Library 10.mq5 to my personal needs I just thought it is worth mentioning that it really helped me to add the method
void CSpinEdit::LabelText(const string new_text)
to the class CSpinEdit doing nothing but deferring any call to CLabel::Description(const string new_text). The reason is that I am using a CSpinEdit for different types of values depending on the state of a CComboBox. After changing label with LabelText(text) and choosing the appropriate edit format the values are displayed as desired after calling
void CSpinEdit::ChangeValue(const double value)
Thanks again and Regards
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Graphical Interfaces VI: the Checkbox Control, the Edit Control and their Mixed Types (Chapter 1) has been published:
This article is the beginning of the sixth part of the series dedicated to the development of the library for creating graphical interfaces in the MetaTrader terminals. In the first chapter, we are going to discuss the checkbox control, the edit control and their mixed types.
The Checkbox Control
The checkbox control is designated to managing parameters that can have only two states. A button with two icons is used to identify the current state of the parameter to which the control is attached. The icon with the check symbol means that the parameter is enabled (on). The icon without the check symbol means the parameter is disabled (off). A brief description of the parameter is located near the button.
This element will be composed of three graphical objects. They are:
Fig. 1. Compound parts of the checkbox control.
Author: Anatoli Kazharski