主题:MFC中嵌入matlab的Figure图
我参照matlab与vc混合编程的书,写了下面一段代码:
char wnd_name[]="wndname";
mwArray mwWndname(wnd_name);
mwArray mwShowWnd(1,1,mxDOUBLE_CLASS,mxREAL);
double showwnd=1.0;
mwShowWnd.SetData(&showwnd,1);
GetDatabase(mwWndname,mwShowWnd);
HWND hFig=::FindWindow(NULL,wnd_name);
if(hFig==NULL)
{
MessageBox("Failed to find the figure window");
return;
}
::ShowWindow(hFig,SW_HIDE);
CRect figure_rect;
CWnd *myfigure=GetDlgItem(IDC_STATIC);
myfigure->GetWindowRect(&figure_rect);
long fig_width=figure_rect.Width();
long fig_height=figure_rect.Height();
::SetParent(hFig,myfigure->GetSafeHwnd());
long lStyle=::GetWindowLong(hFig,GWL_STYLE);
::SetWindowLong(hFig,GWL_STYLE,lStyle&(~WS_CAPTION)&(~WS_THICKFRAME));
::ShowWindow(hFig,SW_SHOW);
::SetWindowPos(hFig,NULL,0,0,fig_width,fig_height,SWP_NOZORDER|SWP_NOACTIVATE);
::ShowWindow(hFig,SW_SHOW);
::SetForegroundWindow(this->m_hWnd);
结果,提示我Failed to find the figure window!而且Figure图也显示出来了,但是没有嵌入到MFC中,请问这是怎么回事呢?请高手指教!!不胜感激!!
char wnd_name[]="wndname";
mwArray mwWndname(wnd_name);
mwArray mwShowWnd(1,1,mxDOUBLE_CLASS,mxREAL);
double showwnd=1.0;
mwShowWnd.SetData(&showwnd,1);
GetDatabase(mwWndname,mwShowWnd);
HWND hFig=::FindWindow(NULL,wnd_name);
if(hFig==NULL)
{
MessageBox("Failed to find the figure window");
return;
}
::ShowWindow(hFig,SW_HIDE);
CRect figure_rect;
CWnd *myfigure=GetDlgItem(IDC_STATIC);
myfigure->GetWindowRect(&figure_rect);
long fig_width=figure_rect.Width();
long fig_height=figure_rect.Height();
::SetParent(hFig,myfigure->GetSafeHwnd());
long lStyle=::GetWindowLong(hFig,GWL_STYLE);
::SetWindowLong(hFig,GWL_STYLE,lStyle&(~WS_CAPTION)&(~WS_THICKFRAME));
::ShowWindow(hFig,SW_SHOW);
::SetWindowPos(hFig,NULL,0,0,fig_width,fig_height,SWP_NOZORDER|SWP_NOACTIVATE);
::ShowWindow(hFig,SW_SHOW);
::SetForegroundWindow(this->m_hWnd);
结果,提示我Failed to find the figure window!而且Figure图也显示出来了,但是没有嵌入到MFC中,请问这是怎么回事呢?请高手指教!!不胜感激!!