15,979
社区成员
发帖
与我相关
我的任务
分享
comSin->guitest(); //绘制图像窗体并显现 (其实是Matlab窗体)
// char FigName[] = "TestCOM";
HWND hFig ;
do
{
hFig = ::FindWindow(NULL,_T("TestCOM") ) ; //获取要嵌入的窗体
} while (NULL == hFig);
if(!hFig)
{
AfxMessageBox("No figure found") ;
}
long lStyle = ::GetWindowLong(hFig,GWL_STYLE); //去掉图像标题
::SetWindowLong(hFig,GWL_STYLE,lStyle & (~WS_CAPTION) &(~WS_THICKFRAME)) ;
::SetWindowPos(hFig,NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
RECT plotRect ;
CWnd *plotArea = NULL ;
do
{
plotArea = GetDlgItem(IDC_STATIC) ; //获取Picture控件句柄
} while (NULL == plotArea);
if (NULL == plotArea)
{
AfxMessageBox("plotArea us NULL") ;
}
plotArea->GetWindowRect(&plotRect) ;
plotArea->ModifyStyle(0, WS_CLIPSIBLINGS, 0);
long width = plotRect.right - plotRect.left;
long height = plotRect.bottom - plotRect.top ;
HWND hresult = NULL ;
do
{
hresult = ::SetParent(hFig,plotArea->GetSafeHwnd());
// AfxMessageBox("Set matlab figure into picture") ; //这个地方最奇怪了,如果弹出对话框,就能显示嵌入到Picture控件的图像,注释掉后不显示。
} while (NULL == hresult);
::SetWindowPos(hFig,NULL,1,1,width-3,height-3,SWP_NOZORDER | SWP_NOACTIVATE) ;