Matlab plots directly inside c++ GUI

2020-07-23 04:13发布

I'm using matlab compiler to generate c++ shared library from my m files. Is it possible to display matlab plots directly inside c++ GUI (not in a separate window) ?

2条回答
Ridiculous、
2楼-- · 2020-07-23 04:57

MATLAB uses JIDE, which is built on Java/Swing for their user interface. Embeddable figures have not been available for MATLAB Builder JA as well. Therefore I think, according to stijn, there are no embeddable plots. I would love to be proven wrong.

查看更多
Summer. ? 凉城
3楼-- · 2020-07-23 05:00

I found easy solution. If you are using windows you could just setparent to matlab window. something like this.

HWND h = FindWindow(L"SunAwtFrame", L"Figure 1");

void MatlabViewerHack::EmbedMatlabPlot(HWND h)
{
   SetWindowPos(h,NULL,rect.left(), rect.top(), rect.width(), rect.height(),0);
   SetWindowLong(h, GWL_STYLE,WS_CHILD|WS_VISIBLE);
   SetParent(h, parent_widget);             //dynamic_cast<QWidget*>(parent())->winId()

   //updating ui_state, windows xp, window 7
   SendMessage(h, WM_UPDATEUISTATE, UIS_INITIALIZE, 0);
   SendMessage(parent_widget, WM_UPDATEUISTATE, UIS_INITIALIZE, 0);
   SendMessage(h, WM_CHANGEUISTATE, UIS_INITIALIZE, 0);
   SendMessage(parent_widget, WM_CHANGEUISTATE, UIS_INITIALIZE, 0);

   current_window = h;
}
查看更多
登录 后发表回答