How to build a matlab figure inside a winform application?

I have a matlab ml file that displays some function. Using matlab, I created a network build project, and finally I got a DLL to work. I have a winform application created in visual studio using C # and I call my DLL (generated in Matlab) from my application. Finally, I get the graph in a new window (figure command in matlab). For example, it looks like this: http://i.stack.imgur.com/cbq5Z.png

Can I embed a Matlab shape in my winform application?

http://i.stack.imgur.com/S9V9s.png Saving an image in Matlab and loading it into a picturebox in winform is not a good solution, because I need to control the shape (scaling, rotation in 3d).

+6
source share
1 answer

Matlab graphs directly inside C ++ GUI

That's what you need. You need to import the FindWindow () method from User32.dll. It returns a pointer to a window whose name you pass as the second argument. After you receive the pointer, you must set its parent using the SetParent () method, which you can also get from User32.dll. To get a pointer to your form, use this.Handle:

IntPtr foundWindow = FindWindow("SunAwtFrame", "Figure 1"); //I belive, this shall give you a pointer to your Matlab window SetParent(foundWindow, this.Handle); 

And you can control the position and size of foundWindow using SetWindowPos () and SetWindowLong () (import them from User32.dll).

+4
source

Source: https://habr.com/ru/post/971920/


All Articles