创建动态视图 [英] Creating dynamic view
本文介绍了创建动态视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用动态视图创建一个SDI应用程序。
我发现通常使用下面的代码在应用程序类的函数InitInstance()内创建视图。
Hi,
I want to create a SDI application with dynamic views.
I found that normally the view is created inside the function InitInstance() of application class using the code below.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyAppDoc),
RUNTIME_CLASS(CMyMainFrame), // main SDI frame window
RUNTIME_CLASS(CMyAppView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
if (!ProcessShellCommand(cmdInfo))
return FALSE;
我想根据用户输入创建视图...例如,选择组合框中的项目。 />
如何在InitInstance()函数外创建视图???
请帮助..
I want to create the view based on the user input...for eg, on selecting an item in combobox.
How should i create a view outside the InitInstance() function???
Please help..
推荐答案
此处的视图不是在InitInstance()
中创建的。当创建新(空)文档或打开现有文档时,视图将由CMyAppDoc
类创建。在你的代码中,这是通过调用ProcessShellCommands()来启动的。
如果你需要不同类型的视图,你可以在InitInstance中添加多个模板( )
必须是CMultiDocTemplate
类型,并使用其中一个来创建框架窗口(这是视图的父窗口)CMyAppDoc
class。
虽然您的应用程序仍然是SDI,但这需要您的<$ c $中的一些工作c> CMyAppDoc 类。要创建一个框架(例如,从文档类的OnNewDocument()
和OnOpenDocument()
),请调用CreateNewFrame()
和InitialUpdateFrame()
所选CMultiDocTemplate
将指针传递给您的文档类。
The view is not created here inInitInstance()
. The view will be created by theCMyAppDoc
class when a new (empty) document is created or an exiting one is opened. In your code this is initiated by calling ProcessShellCommands().
If you need different kinds of views, you can add multiple templates inInitInstance()
which must be of typeCMultiDocTemplate
and use one of them to create the frame window (which is the parent window of the view) from within yourCMyAppDoc
class.
While your application is then still SDI, this requires some work in yourCMyAppDoc
class. To create a frame (e.g. from withinOnNewDocument()
andOnOpenDocument()
of your document class), call theCreateNewFrame()
andInitialUpdateFrame()
member functions of the selectedCMultiDocTemplate
passing the pointer to your document class.
这篇关于创建动态视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文