一个关于文档视图的巨难的问题,csdn的所有高手请帮忙,实在不行请置顶。

scmsir 2004-07-13 05:31:08
我使用文档视图模式、并且使用资源管理器风格,在程序打开的时候不显示视图,用户选择菜单后显示对应的视图,并且在用户单击视图上的一个推出按钮的话,视图关闭,直到用户开外选择菜单。视图为FormView。
关键的问题在于我想在用户选择菜单后,进行相应的操作。
比如用户选择管理数据。那么在左边显示所有的数据,在右边的窗口显示添加、删除、修改等按钮。
各位高手帮忙看看,如果有思路的话尽可能再加上一些源码!因为我就是有一些思路但是一写代码的时候就不行了。
...全文
154 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
baijuyi 2004-07-25
  • 打赏
  • 举报
回复
搂主,强烈建议使用formview,然后添好控件,将所有的设为不可显得。然后根据需要显示。
scmsir 2004-07-14
  • 打赏
  • 举报
回复
把老大都惊动了实在不好意思,但是对这个东西我真得不懂呀,如果例子多的话各位给我发个例子吧。scmsir@yahoo.com.cn.
看这些理论实在是不懂。
蒋晟 2004-07-13
  • 打赏
  • 举报
回复
不要动不动就说你的问题多么的难,这对别人解决你的问题一点帮助没有。
不要动不动就叫全论坛的人,这也对别人解决你的问题一点帮助没有。
此类问题的解答MSDN里面就有,而且我在这里已经解答过无数次了,不值得为此置顶。
Visual C++/MFC Frequently Asked Questions
Scot Wingo
Stingray Software
Version 5.0, updated May 15, 1997
Version 5.6, updated July 14, 1998, and added as a downloadable file to this document
MSDN Editor's Note, May 1997 This document was copied with permission from the "Microsoft Visual C++/Microsoft Foundation Classes (MFC) Frequently Asked Questions (aka the MFC FAQ)," written and compiled by Scot Wingo and sponsored by Stingray Software. You can find out more about Stingray Software's products at www.stingray.com/.
If you have any questions or comments concerning the MFC FAQ, please address them to mfc_faq@stingsoft.com.
This FAQ is not produced or checked for technical accuracy by Microsoft Corporation.
MSDN Editor's Note, August 1998 The folks at Stingray Software have updated their popular Visual C++/Microsoft Foundation Classes (MFC) Frequently Asked Questions. Because Stingray provided us with the newest revision in the form of an HTML Help document (a .chm file), we have elected to include it below as a downloadable file. To open version 5.6, just download and then double-click mfcfaq.chm.

How do I keep my application from creating a new document at startup?

Add this call:

cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing

just before the call to ProcessShellCommand in the app's InitInstance.

lechner-cos1@kaman.com, email, 1/6/96

How do I create multiple views on one document?

The CDocTemplate::CreateNewFrame() function creates additional views of a document in an MDI application written with MFC. To call this function, specify a pointer to a CDocument object (the document for which the function will create a view) and a pointer to a frame window that has the properties to duplicate. Typically, the second parameter of this function is NULL.

When an application calls CreateNewFrame(), the function creates a new frame window and a view in the frame window. The frame window type and view type depend on the document template (CDocTemplate) associated with the document specified in the CreateNewFrame() call.

The CHKBOOK MFC sample application that ships with Visual C++ also demonstrates creating additional frames and views for documents. Check out CHKBOOK.CPP, the CChkBookApp::OpenDocumentfile() function.

Another example of using CreateNewFrame() is the MULTVIEW sample application.

CreateNewFrame() creates both a frame and a view; not only a view. If, for some reason, CreateNewFrame() does not quite address your situation, the source code for CreateNewFrame() is quite useful to demonstrate the steps required to create frames and views.

Visual C++ Knowledge Base article Q100993 with mods, 6/25/95

kongyunzhongque 2004-07-13
  • 打赏
  • 举报
回复
一个MDI就可以搞定了,在APP层映射菜单,有一个普通的cchildframe,和具有分割条的cchildframe框架

app初始化时
// DON'T display a new MDI child window during startup!!!
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

void C×××App::BIOpenDocument(CRuntimeClass *pViewClass, CString strDocName,
short nSplitterViewType /* = -1*/)
{
CDocTemplate* pDocTemple;
CDocument *pDoc;
CView* pView;
CString strReturn;

m_nSplitterViewType = nSplitterViewType;

POSITION pos = GetFirstDocTemplatePosition();
while (pos != NULL)
{
pDocTemple = GetNextDocTemplate(pos);
pDocTemple->GetDocString(strReturn, CDocTemplate::docName);
if (strReturn == strDocName)
{
TRACE("C***App Find %s DocTemple OK!\n", strDocName);

if (m_mapStringToOb.Lookup(strDocName, (CObject *&)pDoc))
{
ASSERT(pDoc != NULL);

POSITION posView = pDoc->GetFirstViewPosition();
while (posView != NULL)
{
pView = pDoc->GetNextView(posView);
if (pView->IsKindOf(pViewClass))
{
pView->GetParentFrame()->ActivateFrame();
return;
}
}
}
else
{
pDoc = pDocTemple->OpenDocumentFile(NULL);
m_mapStringToOb.SetAt(strDocName, (CObject *)pDoc);
}
}
} //End while
}

void C×××App::OnInfo()
{
BIOpenDocument(RUNTIME_CLASS(C×××View), _T("Info"), CINFOVIEW);
}

BOOL CSplitterFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// create a splitter with 2 rows, 1 column
if (!m_wndSplitter.CreateStatic(this, 2, 1))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}

// add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
pContext->m_pNewViewClass, CSize(130, 200), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}

// add the second splitter pane - an input view in column 1
switch (theApp.m_nSplitterViewType)
{
case CINPUTVIEW:
if (!m_wndSplitter.CreateView(1, 0,
RUNTIME_CLASS(CShippingShowView), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
break;
case CINFOVIEW:
if (!m_wndSplitter.CreateView(1, 0,
RUNTIME_CLASS(CInfoShowView), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
break;
}

// activate the input view
SetActiveView((CView*)m_wndSplitter.GetPane(0,0));

return TRUE;

}

视图关闭可以用GetParentFrame()->SendMessage(WM_CLOSE,0,0);
GameWeaverDummy 2004-07-13
  • 打赏
  • 举报
回复
syy64 2004-07-13
  • 打赏
  • 举报
回复
产生两个工程,个是基于对话框的,一个是基于单文档(或多文档),将两个工程合并;
看一下MFC自带的例子(MDI),在msdn里面。

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧