Creating a GUI for MQLs in graphical mode. - page 5

 

Here's an example of a simple form drawn in Sharpe in 10 minutes with an EA. The form receives ticks from chart, directly from EA as from native dll, without sockets, files and other things. And the form is attached to the chart. There is some problem with the attachment that has to be solved. But it is possible not to attach it, whatever you like.

 
Алексей Барбашин:

Here's an example of a simple form drawn in Sharpe in 10 minutes with an EA. The form receives ticks from chart, directly from EA as from native dll, without sockets, files and other things. And the form is attached to the chart. There is some problem with the attachment that has to be solved. But it can not be attached - whatever you like.

Tell me which compiler from GitHub you used. Or did you edit sharp compiled by hand? I don't need it. It's easier to write C++ DLL in mixed code (managed + unmanaged).

 
Yuriy Asaulenko:

Tell me which compiler from GitHub you used. Or did you edit the sharded compile by hand? Not a good idea. It's easier to write C++ DLL in mixed code (managed + unmanaged).

I wrote in the previous post: everything is done with VS in-house tools. I am using VS 2017 Community. Just at the beginning of the project the DllExport library with Nuget is connected to it. Nothing needs to be finalized manually after compiling the project, from the word TOTALLY.

I don't recommend the template fromR.Giesecke. Here with it there is a real tambourine, if at all it will be possible to start. With this library you won't even feel the difference. Your dll itself "becomes native" during normal compilation.

 
Алексей Барбашин:

I wrote in the previous post: everything is done with VS in-house tools. I am using VS 2017 Community. Just at the beginning of the project, the DllExport library with Nuget is connected to it. Nothing needs to be finalized by hand after compiling the project, from the word EVERYTHING.

Yes, yes, exactly with Nuget. It did not work for me, but there was a non-standard DLL for interaction with the C-API, + more callback functions. I don't know, for some reason I remembered it as a compiler, or that was a different solution.

And in this case, the solution is really good and simple.

 
Алексей Барбашин:

Why the left one? Everything is done with VS's in-house means. Nuget has the DllExport library, which modifies the System.Runtime.InteropServices class once, and then everything compiles normally. So no tambourine dancing is required, no wrappers are required. Creating forms is much easier in c# than writing them in an additional file, as Maxim suggests. I respect Maxim and his work, but in this case the Net world is open to us without any additional difficulties.

It's interesting, have you checked it yourself? I used to make MT4 - C++dll - C#dll connection, I couldn't load C#dll directly.

https://www.nuget.org/packages/DllExport/ is it?

DllExport 1.6.0
DllExport 1.6.0
  • www.nuget.org
The open implementation of unmanaged exports for .NET ( DllExport )        Source code and all details here: https://github.com/3F/DllExport                To configure projects via current package:        ========================================================        DllExport -action Configure -dxp-version 1.6.0...
 
Алексей Барбашин:

I wrote in the previous post: everything is done with VS in-house tools. I am using VS 2017 Community. Just at the beginning of the project, the DllExport library with Nuget is connected to it. Nothing needs to be finalized manually after compiling the project, from the word TOTALLY.

I don't recommend the template fromR.Giesecke. Here with it there is a real tambourine, if at all it will be possible to start. With this library you won't even feel the difference. Your dll will "become native" during normal compilation.

Tzek, can you elaborate? The task for the example is to make a panel in C# that gets information from the EA and sends it commands. How to use dllexport for this?

No need to spell it out, just steps, what and how does it react to each other?

 
Alexey Volchanskiy:

It's interesting, have you checked it yourself? I used to do MT4 - C++dll - C#dll link, couldn't load C#dll directly.

https://www.nuget.org/packages/DllExport/ is it?

Of course I checked it. I gave an example of dll creation with form above.

 
Алексей Барбашин:

Of course I did. I gave an example of dll with a form above.

Is this picture an example?

All right, I'll take care of it myself.

 
Alexey Volchanskiy:

Tezka, can you elaborate? The task for the example is to make a panel in C#, which receives information from the EA and sends it commands. How to use dllexport for this?

No need to spell it out, just steps, what and how does it react with each other?

1. Create a project in c# Class Library (net Framework)

2. Add the DllExport library from NuGet to the project. It is better to download it from the server. Put the batch file in the project folder.

3. We launched the library through the command line (there is a video on the hub) and modified the System.Runtime.InteropServices.

At this point all the preparations are completed. Restarting the project

4. Create an export function and add the [DllExport]y modifier before it. If step 3 is correctly performed, the compiler will not complain about the modifier

5. Add the form to the project and make it up as required.

6. Add to the class of exported functions (created at step 1) function of opening the form, for example, Start

7. Create function to open form, for example OpenDialog, as it is done in the main function when creating an application on windows form

8. In the Start function, create a thread for which we specify the OpenDialog function as the executable method

9. Create an EA/indicator/script and connect the dll as usual. ))

10. Call the Start function from mql

The form will be started in a separate thread and will not stop the process in mql as a normal modal dialog would.

Data transfer from mql to a form is done in the same way as data transfer between classes and threads of the application itself.

1. Create a function in a class to be exported which will be called by mql to transfer data; for example, SendTick.

Remember, that mql will see only those class methods (functions), which have the [DllExport] modifier installed.

2. Create an event delegate in this class with parameters

3. In the form we need to subscribe to the event of the exported class

4. When calling SendTick method from mql, we call the created event and pass the parameters

5. In the form, we create an event handler that intercepts the event and sends the data to the form, or does something else.

That's all. Nothing else is required.

Just in case the form and the export class are working in different threads, so to put information on the form we need a data processing delegate from the adjacent thread.

If you succeed, please share the "result" and impressions of the simplicity. )))

The most "difficult" in all this will be installation of the library. )))

 
Alexey Volchanskiy:

Is this picture an example?

I see, I'll figure it out myself.

Alexey, I have detailed the picture. )) If you have any more questions, ask me, I'll try to answer them!