Discussion of article "Developing graphical interfaces for Expert Advisors and indicators based on .Net Framework and C#" - page 14
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
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?