![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Found an interesting window. It is almost impossible to catch anything in it. The window is called "Save as". Can you tell me how to press the "Save" button?
If you select the save button specifically, you have the button code 00000001
But nothing happens when calling it by this code. What is this unnamed window?
This is a popup dialog box. Its system descriptor can be obtained using the WinAPI function GetLastActivePopup(int hWnd).
Here is an example of how to use this function:
The checkboxes can be ticked programmatically if they are not present.
What Win API functions are used to do this?
Found a function in the WinAPI:
CheckDlgButton function
Description:function CheckDlgButton(Dlg: HWnd; IDButton: Integer; Check: Word);
Marks or unmark a button control or changes the state of a three-button control.
Parameters:Dlg: The dialog box that contains the button.
IDButton: The modifiable control of the button.
Checks: deleted(0), marked(1), shaded(2).
Before executing it which function to check the state of the button. In my case it is in the checkbox.
in continuation of the API theme
when saving - if this happens again the question will arise!
save as
( file exists replace )
hit YES automatically
Found a function in the WinAPI:
CheckDlgButton function
Description:function CheckDlgButton(Dlg: HWnd; IDButton: Integer; Check: Word);
Labels or unchecks a button control or changes the state of a three-button control.
Parameters:Dlg: The dialog box that contains the button.
IDButton: The modifiable control of the button.
Checked: deleted(0), marked(1), shaded(2).
Before executing it which function to use to check the state of the button. In my case in checkbox.
You can use the IsDlgButtonChecked function to determine the current state of the switch:
This function returns the state of the switch with idButton located in the hdlg dialog box. If the switch is in a disabled state, a null value is returned. A value of 1 is returned for a switch that is on. A value of 2 corresponds to an inactive switch, shown in grey. In case of an error, a negative value of -1 is returned.
---
An example of how IsDlgButtonChecked works can be seen here
http://frolov-lib.ru/books/bsp/v12/ch3_2.htm
Decided to get back to the subject of WinAPI study.
I'm trying to use Microsoft Spy++ v.9.00.21022 to find the identifier of the "Optimization" checkbox in order to check whether it is ticked or not.
I do the following step by step.
1. Started terminal.
2. opened tester window.
3. In Spy++ I searched for a window and pointed to the "Optimize" element.
Clicked OK button.
4. Running through the tabs of the next window
I can't figure out where my code for this button is.
Ilnur ,YuraZ and others teach me to identify this descriptor code I need.
Why do I ask to teach you, not to point specifically to the codes, because I want to learn to identify other elements. Although if you specify it may be easier for me to find them later, knowing what to look for and where to look....
Here I have given a code example on how to find the identifier of the "Start" button.
The same figure shows how to find the identifier of the control.
All controls located in the strategy tester window are defined in the same way.
For example, according to the picture above, the identifier of the "Optimization" checkbox (General tab) is 0x405.
I've got it sorted out. The only thing I can't find codes of 2 buttons - date for testing and optimization from "Date" to "Date". Program outputs 00000001. Ilnur tell me the codes of these buttons.
Yes, indeed, the identifiers of these items are the same. Therefore, we cannot use GetDlgItem() in this case.
This leaves the option of identifying them using FindWindowExA(). However, the main question is whether we need to identify them.
It is not possible to manage these items, i.e. to specify the optimization or testing period, by means of the WinAPI in MQL.
Although I may be wrong.
Yes, indeed, the identifiers of these items are the same. Therefore, we cannot use GetDlgItem() in this case.
This leaves the option of identifying them using FindWindowExA(). However, the main question is whether we need to identify them.
The possibility to manage these items, i.e. to specify optimization or testing period, by means of the WinAPI in MQL is missing.
I may be wrong though.
find an item with ID - 0x0577 (click on Change Expert button)
and click NextWindow 3 times just to get into the From date field: then try NextWindow twice more and we will get into the To date field:
in both cases just fill date fields
SetWindowTextA( hwndEditDATEbeg, sDateBeg);
SendMessageA(hwndEditDATEbeg, EN_UPDATE, _ID_EDIT_HEX_DATEbeg, 0);
SendMessageA(hwndEditDATEbeg, EN_CHANGE, _ID_EDIT_HEX_DATEbeg, 0);
..
In MSQL5 I'd really like to get a built-in tool for communication with the tester...