多文档编程,怎么可以在打开时直接显示自己创建的几个视图!拜大侠!
多文档编程,如何可以在打开时直接显示自己创建的几个视图!拜大侠!!!
这个是我用来注册的代码:
CMultiDocTemplate *pCImageViewDocTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CImageView)); // view class
AddDocTemplate(pCImageViewDocTemplate);
CMultiDocTemplate *pCurveViewDocTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CCurveView)); // view class
AddDocTemplate(pCurveViewDocTemplate);
CMultiDocTemplate *pCDataViewDocTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CDataView)); // view class
AddDocTemplate(pCDataViewDocTemplate);
这个是我准备建立多个文档模板。。。公用一个Doc。。。
CMultiDocTemplate *pDocChiidTemplate;
pDocChiidTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CCurveView)); // view class
AddDocTemplate(pDocChiidTemplate);
pDocChiidTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CImageView)); // view class
AddDocTemplate(pDocChiidTemplate);
pDocChiidTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CCurveView)); // view class
AddDocTemplate(pDocChiidTemplate);
上面的是我想建立一个模板,管理一个Doc, 管理多个视图,请问这么用可以吗????
CMultiDocTemplate *pDocChiidTemplate;
pDocChiidTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CDataView)); // view class
AddDocTemplate(pDocChiidTemplate);
POSITION pDocPosition = pDocChiidTemplate->GetFirstDocPosition();
CDocument *pd = pDocChiidTemplate->GetNextDoc(pDocPosition);
CImageView *m_Image;
CCurveView *m_Curve;
pd->AddView(m_Image);
pd->AddView(m_Curve);
这个是我想建立在一个文档模板类里面添加视图,这么做的时候pDocPosition获得不到值,这是为什么?这么做行不行
下面是我用来显示的代码:
第一段::::
pDocPosition = pDocChiidTemplate->GetFirstDocPosition();
while(pDocPosition != NULL)
{
CDocument *pDocument = pDocTemplate->GetNextDoc(pDocPosition);
POSITION pViewPosition = pDocument->GetFirstViewPosition();
while(pViewPosition != NULL)
{
CView * pView = pDocument->GetNextView(pViewPosition);
if (pView->IsKindOf(RUNTIME_CLASS(CCurveView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
if (pView->IsKindOf(RUNTIME_CLASS(CImageView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
if (pView->IsKindOf(RUNTIME_CLASS(CDataView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
}
CMDIChildWnd *pNewFrame = (CMDIChildWnd *)pDocTemplate->CreateNewFrame(pDocument, NULL);
pDocTemplate->InitialUpdateFrame(pNewFrame, pDocument);
}
第二段:::
pDocPosition = pCImageViewDocTemplate->GetFirstDocPosition();
while(pDocPosition != NULL)
{
CDocument *pDocument = pDocTemplate->GetNextDoc(pDocPosition);
POSITION pViewPosition = pDocument->GetFirstViewPosition();
这个是我用来注册的代码:
CMultiDocTemplate *pCImageViewDocTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CImageView)); // view class
AddDocTemplate(pCImageViewDocTemplate);
CMultiDocTemplate *pCurveViewDocTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CCurveView)); // view class
AddDocTemplate(pCurveViewDocTemplate);
CMultiDocTemplate *pCDataViewDocTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CDataView)); // view class
AddDocTemplate(pCDataViewDocTemplate);
这个是我准备建立多个文档模板。。。公用一个Doc。。。
CMultiDocTemplate *pDocChiidTemplate;
pDocChiidTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CCurveView)); // view class
AddDocTemplate(pDocChiidTemplate);
pDocChiidTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CImageView)); // view class
AddDocTemplate(pDocChiidTemplate);
pDocChiidTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CCurveView)); // view class
AddDocTemplate(pDocChiidTemplate);
上面的是我想建立一个模板,管理一个Doc, 管理多个视图,请问这么用可以吗????
CMultiDocTemplate *pDocChiidTemplate;
pDocChiidTemplate = new CMultiDocTemplate(
IDR_WJ200TYPE,
RUNTIME_CLASS(CWJ200Doc), // document class
RUNTIME_CLASS(CChildFrame), // frame class
RUNTIME_CLASS(CDataView)); // view class
AddDocTemplate(pDocChiidTemplate);
POSITION pDocPosition = pDocChiidTemplate->GetFirstDocPosition();
CDocument *pd = pDocChiidTemplate->GetNextDoc(pDocPosition);
CImageView *m_Image;
CCurveView *m_Curve;
pd->AddView(m_Image);
pd->AddView(m_Curve);
这个是我想建立在一个文档模板类里面添加视图,这么做的时候pDocPosition获得不到值,这是为什么?这么做行不行
下面是我用来显示的代码:
第一段::::
pDocPosition = pDocChiidTemplate->GetFirstDocPosition();
while(pDocPosition != NULL)
{
CDocument *pDocument = pDocTemplate->GetNextDoc(pDocPosition);
POSITION pViewPosition = pDocument->GetFirstViewPosition();
while(pViewPosition != NULL)
{
CView * pView = pDocument->GetNextView(pViewPosition);
if (pView->IsKindOf(RUNTIME_CLASS(CCurveView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
if (pView->IsKindOf(RUNTIME_CLASS(CImageView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
if (pView->IsKindOf(RUNTIME_CLASS(CDataView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
}
CMDIChildWnd *pNewFrame = (CMDIChildWnd *)pDocTemplate->CreateNewFrame(pDocument, NULL);
pDocTemplate->InitialUpdateFrame(pNewFrame, pDocument);
}
第二段:::
pDocPosition = pCImageViewDocTemplate->GetFirstDocPosition();
while(pDocPosition != NULL)
{
CDocument *pDocument = pDocTemplate->GetNextDoc(pDocPosition);
POSITION pViewPosition = pDocument->GetFirstViewPosition();