Discussion of article "Developing graphical interfaces for Expert Advisors and indicators based on .Net Framework and C#" - page 11

 

great work!

sometimes the MT5 will crash when i close a form, of course, there is a unhandled exception, but i don't know where is the code and can't catch it. do you have any ideas?

do you have any ideas?

 
Artur Zas:

The code in the example is WinForms specific, but you can easily alter it for use with WPF. You just need to bind to different events on the WPF shell side. The code will be a bit different but the principles will remain the same.

You can also use the code as is if you just use the WinForms window as a host for XAML controls. You can do this with the new XAML Islands. This way you can use all of the modern UWP controls inside a WinForm.

How can we do the first, cause I'm trying to include the window class instead form on the Visual Studio Program but that dont' Works. Or know you other .dll able to work with MQL5 and WPF?
 

Good afternoon! For some reason it doesn't compile, what am I doing wrong? I put the file MtGuiController.dll in the Libraries folder.


 
Copyright © 2020 ®kwancheetuck All rights reserved via. Deposit Ownership MQL5
.
 
Vasiliy Sokolov:

I'd like to launch spaceships into space. I've got lots of ideas, but I can't get my hands on them either.

And in general it's congenial: it's hard to download the studio, but to write down the XAML interpreter yourself - it's nothing, but I just can't get my hands on it.

))

 
Rafil Nurmukhametov:

Good afternoon! For some reason it doesn't compile, what am I doing wrong? I put the file MtGuiController.dll in the Libraries folder.


Rafil, did you find out what the problem was?

 
#import  "MtGuiController.dll"
string assembly = "C:\\MT5\\Form1.exe";

//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   GuiController::ShowForm(assembly, "Form1");
   EventSetMillisecondTimer(200);   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialisation function|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   printf("enter deinit");
   GuiController::HideForm(assembly, "Form1");
   printf("exit deinit");
   EventKillTimer();
   
  }
//+------------------------------------------------------------------+
//| Expert tick function|
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function|
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   for(static int i = 0; i < GuiController::EventsTotal(); i++)
   {
      int id;
      string el_name;
      long lparam;
      double dparam;
      string sparam;
      GuiController::GetEvent(i, el_name, id, lparam, dparam, sparam);
// if(id == ClickOnElement)
      if(id == 9)
         printf("Click on element " + el_name);
   }
  }
//+------------------------------------------------------------------+

@Vasiliy Sokolov, can you help me to understand this?

Take GuiMtController.mq5, put the library in Libraries, .exe in c:\\MT\\\\, define assembly accordingly.

Compile and we get a message about an undefined ClickOnElement variable. Let's say we replace it with any integer -> compile normally, but the form itself doesn't start. Of course, dlls are allowed, Metaeditor build 2361

 

Maybe someone else will stumble

here's the place in the article

"As you can see, the compiler understands external enums defined in Net-libraries and knows how to work with them."

I don't know yet 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 in the opposite way )).

But in general, the coolest thing has turned out. Thank you for your labour!)

Документация по MQL5: Основы языка / Типы данных / Целые типы / Перечисления
Документация по MQL5: Основы языка / Типы данных / Целые типы / Перечисления
  • www.mql5.com
После объявления перечисления появляется новый целочисленный 4-байтовый тип данных. Объявление нового типа данных позволяет компилятору строго контролировать типы передаваемых параметров, так как  перечисление вводит новые именованные константы. В приведенном примере именованная константа January имеет значение 0, February имеет значение 1...
 
Nikolai Karetnikov:

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!)

Wait to get excited. Check if the tables work. This issue remained unclear. There were huge delays when outputting data at high frequency.
 
Реter Konow:
Wait to get excited. Check to see if the tables are working. This issue remained unclear. There were huge delays when outputting data at high frequency.

Afternoon! )

Peter, what do you mean "were" and what do you mean by "high"? There was a discussion on this topic somewhere or something