按照顺序找GetPlcView

CPlcView* GetPlcView()
{
POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition(); //paramview
AfxGetApp()->GetNextDocTemplate(pos); //formview
AfxGetApp()->GetNextDocTemplate(pos); //plcview
if (pos)
{
CDocTemplate* pDocTemp = AfxGetApp()->GetNextDocTemplate(pos); //获取文档模板位置

if (pDocTemp)
{

POSITION dPos = pDocTemp->GetFirstDocPosition(); //获取该模板第一个文档位置
if (dPos)
{
CPlcDoc* pDocWnd = (CPlcDoc*)pDocTemp->GetNextDoc(dPos); //获取文档
// if(pDocWnd->GetTitle() == strTitle) //文档标题同样
{

if (pDocWnd)
{
POSITION vPos = pDocWnd->GetFirstViewPosition(); //获取该文档的首个视图位置
if (vPos)
{
CPlcView* pView = (CPlcView*)pDocWnd->GetNextView(vPos);
return pView;
}
}
}
}
}
}
return NULL;
}orm

 

 

 

 

CCmdView* GetCmdView()
{
POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition(); //paramview
AfxGetApp()->GetNextDocTemplate(pos); //formview
AfxGetApp()->GetNextDocTemplate(pos); //plcview
AfxGetApp()->GetNextDocTemplate(pos); //cmdview
if (pos)
{
CDocTemplate* pDocTemp = AfxGetApp()->GetNextDocTemplate(pos); //获取文档模板位置

if (pDocTemp)
{

POSITION dPos = pDocTemp->GetFirstDocPosition(); //获取该模板第一个文档位置
if (dPos)
{
CPlcDoc* pDocWnd = (CPlcDoc*)pDocTemp->GetNextDoc(dPos); //获取文档
// if(pDocWnd->GetTitle() == strTitle) //文档标题同样
{

if (pDocWnd)
{
POSITION vPos = pDocWnd->GetFirstViewPosition(); //获取该文档的首个视图位置
if (vPos)
{
CCmdView* pView = (CCmdView*)pDocWnd->GetNextView(vPos);
return pView;
}
}
}
}
}
}
return NULL;
}文档