i have a matlab m-file, which plots some function. Using matlab, i have created net assembly project and finaly i got a dll to work with. 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 a graph in new window (figure command in matlab). For example, it looks like:
Is it possible to embed a matlab figure into my winform app?
Saving picture in matlab and loading it to picturebox in winform is not a good solution, because i need to operate the figure (zoom, rotate in 3d).
Matlab plots directly inside c++ GUI
This is what you need. You have to import FindWindow() method from User32.dll. It returns a pointer to the window which name you pass as the second argument. After you got the pointer, you have to set it's parent, using SetParent() method, which you can get from User32.dll aswell. In order 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 manage foundWindow position and size using SetWindowPos() and SetWindowLong() (import these from User32.dll).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With