Added native support for .NET libraries with "smart" import of functions. Now you can use .NET libraries without writing special wrappers - MetaEditor takes care of it.
To work with .NET library functions, it is enough to import the DLL itself without specifying specific functions. MetaEditor automatically imports all functions with which it is possible to work: .
Simple structures (POD, plain old data) - structures that contain only simple data types.
Public static functions, in the parameters of which only simple types and POD structures or their arrays are used .
To call functions from the library, just import it: .
Work on .NET libraries support is ongoing, and future versions are planned to expand their use.
Support for working with WinAPI functions has been added to the standard library. Now you don't need to manually import libraries and describe function signatures to use operating system functions in an MQL5 program. It is enough to connect the header file from the MQL5\Include/WinAPI catalogue.
WinAPI functions are grouped in separate files by purpose:
.
libloaderapi.mqh - working with resources
memoryapi.mqh - memory handling
processenv.mqh - working with environment
processthreadsapi.mqh - work with processes
securitybaseapi.mqh - work with OS security system
sysinfoapi.mqh - getting system information
winbase.mqh - general functions
windef.mqh - constants, structures and enumerations
wingdi.mqh - working with graphical objects
winnt.mqh - exception handling
winreg.mqh - working with registry
winuser.mqh - windows and interface management
errhandlingapi.mqh - error handling
fileapi.mqh - file handling
handleapi.mqh - handle handles
winapi.mqh - connection of all functions (WinAPI header files).
Теперь вы можете выносить графики финансовых инструментов за пределы окна торгового терминала. Это удобно при работе с несколькими мониторами. Например, на одном можно расположить основное окно платформы и следить за состоянием счета, а на другом — графики для оценки ситуации на рынке. Чтобы отделить график от терминала, отключите опцию...
Nextor Visual Studio 2022, created a form with a button, run it in MetaTrader 5, I get an error....
In Visual Studio community 2019 everything works as the author did, but when he writes:
"Each form has a public list of elements that it contains. Going through the list of elements, the method finds those that the controller is able to support and subscribes to the events it needs. If an element on the form is not supported by the controller, it will simply be ignored. "
Alas, if you place a SplitContainer or DataGridView on the test form, the form does not start at all, it is not clear why, but such a complex component as Chart STARTED.
I enclose a test example of what components can be used for modification (although the form starts!).
when trying to create a controller GuiController controller = new GuiController(assembly, form, m_global_events); gives Unexpected exception: The key with this name already exists (for DataGridView) and the controller is NOT created (the form is created, probably it can be shown, but without the controller how to control it?).
once again everything is OK if there are no SplitContainer and/or DataGridView components.
"As you can see, the compiler understands external enumerations defined in Net-libraries and knows how to work with them."
I don't know for what reason, but the compiler stubbornly refuses to understand C# enums, so we drag enum from C# into Mql5 and everything works.
Only, Vasily, you have placed the Buy and Sell buttons in the trading panel backwards ))
But in general, the coolest thing has turned out. Thank you for your hard work!)
I had the same problem.
I solved it a little differently - instead of ClickOnElement I wrote GuiEventType::ClickOnElement. And after that it compiles and works without any problems. But if this is the case, it is really unclear how it worked for Vasily. Perhaps I did something wrong...
But otherwise, the thing is really necessary and useful. It's a pity that MQL5 doesn't have something similar (inbuilt).
I solved this problem a little differently - instead of ClickOnElement I wrote GuiEventType::ClickOnElement. And after that it compiles and works without any problems. But if this is the case, it is really unclear how it worked for Vasily. Perhaps I have done something wrong...
But otherwise, the thing is really necessary and useful. It's a pity that MQL5 doesn't have something similar (inbuilt).
I had such an error:
@MQL_User, I did as you did: " ...instead of ClickOnElement wrote GuiEventType::ClickOnElement" - everything worked!
I'm relative new to MQL5 and I learned a lot from this article! Thanks very much!
I have one question. Have been struggling a bit for the past 2 days to figure this out down below.
I have successfully completed each step a couple of times even on another computer but everytime when I try to compile the code I get an error message.
The MQL compiler states : "Undeclared Identifier" for any of the enumerations down below.
If I "comment" these enumerations out from MQL5 then it works accordingly which is interesting since this means that the code works but can't read the enumerations which is my guess?
If someone can help me I would greatly appreciate :)
Thanks,
I read that you need to declare the enums as well in the MQH File as the same exact way that were declared inside the DLL.
An example is given in the announcement https://www.metatrader5.com/ru/releasenotes/terminal/1898.
MQL5
To work with .NET library functions, it is enough to import the DLL itself without specifying specific functions. MetaEditor automatically imports all functions with which it is possible to work:
.
.
To call functions from the library, just import it:
. The C# code of the Inc function of the TestClass class looks like this:
. The script will return the value 42.
Work on .NET libraries support is ongoing, and future versions are planned to expand their use.
WinAPI functions are grouped in separate files by purpose:
.
The binding works only with 64-bit architecture.
In Visual Studio community 2019 everything works as the author did, but when he writes:
"Each form has a public list of elements that it contains. Going through the list of elements, the method finds those that the controller is able to support and subscribes to the events it needs. If an element on the form is not supported by the controller, it will simply be ignored. "
Alas, if you place a SplitContainer or DataGridView on the test form, the form does not start at all, it is not clear why, but such a complex component as Chart STARTED.
I enclose a test example of what components can be used for modification (although the form starts!).
when trying to create a controller GuiController controller = new GuiController(assembly, form, m_global_events);
gives Unexpected exception: The key with this name already exists (for DataGridView) and the controller is NOT created (the form is created, probably it can be shown, but without the controller how to control it?).
once again everything is OK if there are no SplitContainer and/or DataGridView components.
maybe someone else will stumble
this is the place in the article
"As you can see, the compiler understands external enumerations defined in Net-libraries and knows how to work with them."
I don't know for what reason, but the compiler stubbornly refuses to understand C# enums, so we drag enum from C# into Mql5 and everything works.
Only, Vasily, you have placed the Buy and Sell buttons in the trading panel backwards ))
But in general, the coolest thing has turned out. Thank you for your hard work!)
I had the same problem.
I solved it a little differently - instead of ClickOnElement I wrote GuiEventType::ClickOnElement. And after that it compiles and works without any problems. But if this is the case, it is really unclear how it worked for Vasily. Perhaps I did something wrong...
But otherwise, the thing is really necessary and useful. It's a pity that MQL5 doesn't have something similar (inbuilt).
I had the same problem.
I solved this problem a little differently - instead of ClickOnElement I wrote GuiEventType::ClickOnElement. And after that it compiles and works without any problems. But if this is the case, it is really unclear how it worked for Vasily. Perhaps I have done something wrong...
But otherwise, the thing is really necessary and useful. It's a pity that MQL5 doesn't have something similar (inbuilt).
I had such an error:
@MQL_User, I did as you did: " ...instead of ClickOnElement wrote GuiEventType::ClickOnElement" - everything worked!
For MT4, We need to do some changes on MtGuiController.dll. like DLLEXPORT using RGiesecke.DllExport and marshalling input & output parameters.
This does not work for MT4. I tried without any results.
I'm relative new to MQL5 and I learned a lot from this article! Thanks very much!
I have one question. Have been struggling a bit for the past 2 days to figure this out down below.
I have successfully completed each step a couple of times even on another computer but everytime when I try to compile the code I get an error message.
The MQL compiler states : "Undeclared Identifier" for any of the enumerations down below.
If I "comment" these enumerations out from MQL5 then it works accordingly which is interesting since this means that the code works but can't read the enumerations which is my guess?
If someone can help me I would greatly appreciate :)
Thanks,
I read that you need to declare the enums as well in the MQH File as the same exact way that were declared inside the DLL.
For MT4, We need to do some changes on MtGuiController.dll. like DLLEXPORT using RGiesecke.DllExport and marshalling input & output parameters.
string ReceiveEvent(int event_n); // Returns JSON string.. Use JAson.mqh to Deserialize objectsHow do I use this inside OnTimer()?
I am using the same approach as explained in the article
My question is: what int do I need to pass inside the ReceiveEvent function?Sorry for my ignorance but I don't get it.
Can you please tell me what is wrong with the GuiMtController.mq5 program that reports an error when running?