多文档编程,如何可以在打开时直接显示自己创建的几个视图!拜大侠!!!
这个是我用来注册的代码:
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();
while(pViewPosition != NULL)
{
CView * pView = pDocument->GetNextView(pViewPosition);
if (pView->IsKindOf(RUNTIME_CLASS(CImageView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
}
CMDIChildWnd *pNewFrame = (CMDIChildWnd *)pDocTemplate->CreateNewFrame(pDocument, NULL);
pDocTemplate->InitialUpdateFrame(pNewFrame, pDocument);
}
pDocPosition = pCDataViewDocTemplate->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(CDataView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
}
CMDIChildWnd *pNewFrame = (CMDIChildWnd *)pDocTemplate->CreateNewFrame(pDocument, NULL);
pDocTemplate->InitialUpdateFrame(pNewFrame, pDocument);
}
第三段:::
POSITION pTemplatePosition = GetFirstDocTemplatePosition();
while(pTemplatePosition != NULL)
{
CDocTemplate *pDocTemplate = GetNextDocTemplate(pTemplatePosition);
POSITION pDocPosition = pDocTemplate->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(CDataView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
if (pView->IsKindOf(RUNTIME_CLASS(CImageView))) //如果已创建此view 则设其为活动
{
pView->GetParentFrame()->ActivateFrame();
pView->UpdateWindow();
}
}
CMDIChildWnd *pNewFrame = (CMDIChildWnd *)pDocTemplate->CreateNewFrame(pDocument, NULL);
pDocTemplate->InitialUpdateFrame(pNewFrame, pDocument);
}
}
请问怎么能组合出来啊???????????????????直接显示那几个视图窗口啊
[解决办法]
你要想同时显示几个视图,那就得在一个屏里分成几个区域时里显示,比如象有的软件可以设窗口的"平铺"属性就可以让几个窗口排在一起来显示,虽然窗口都变小了.
你看看这个网址对你有没有帮助:
http://www.360doc.com/content/12/0108/15/2013506_178096949.shtml
http://blog.163.com/fk1007@126/blog/static/30036739200921991633565/
http://www.2cto.com/kf/201005/47195.html 这是单文档建立多个视图的方法
http://wgq837051.iteye.com/blog/851915
http://doublez.bokee.com/1742171.html
这么多的资料应该可以满足你的要求了
[解决办法]
http://apps.hi.baidu.com/share/detail/5922312
[解决办法]
http://apps.hi.baidu.com/share/detail/5922312
这个更好
[解决办法]