From: Nick Schultz on
I have a SDI application whose CDocument basically stores a list of packets
sniffed on a bus. The main view is a CListView that displays the packets.

I also have a graphing window that will plot various varible values stored
in the packets. Each graphing window has a list of available varibles to
plot, which the user can select and have graphed. The user can also have
multiple graphs running at the same time. to do this, every time the user
clicks new graph, I create a new graphing window, and when the user clicks
the "X", i then destroy the window.

My question is how do I dynamically create and destroy views at runtime? I
tried looking online however all the information I found was creating a
single view, nothing much on spawning\destroying multiple views. The view
will be placed in my CGrapher class which extends CDockablePane.


thanks,

Nick


From: Joseph M. Newcomer on
Here's some code from one of my projects:

CDocument * CFontExplorerApp::NewItem(CMultiDocTemplate * templ)
{
CDocument * doc = templ->CreateNewDocument();
ASSERT(doc != NULL);
if(doc == NULL)
return NULL;

CFrameWnd * frame = templ->CreateNewFrame(doc, NULL);
if(frame == NULL)
{ /* failed to create */
delete doc;
return NULL;
} /* failed to create */

templ->InitialUpdateFrame(frame, doc, TRUE);
return doc;
} // CFontExplorerApp::NewItem

Note that although I create a multidoc template, I do not call AddTemplate to add it. The
result is a template that specifies the same document, the new view class, the same MDI
Child frame class, and has a new IDR_ menu item (you have to create a new menu item, icon,
and STRINGTABLE resource to go with the new view)
joe

On Fri, 9 May 2008 09:50:04 -0700, "Nick Schultz" <nick.schultz(a)flir.com> wrote:

>I have a SDI application whose CDocument basically stores a list of packets
>sniffed on a bus. The main view is a CListView that displays the packets.
>
>I also have a graphing window that will plot various varible values stored
>in the packets. Each graphing window has a list of available varibles to
>plot, which the user can select and have graphed. The user can also have
>multiple graphs running at the same time. to do this, every time the user
>clicks new graph, I create a new graphing window, and when the user clicks
>the "X", i then destroy the window.
>
>My question is how do I dynamically create and destroy views at runtime? I
>tried looking online however all the information I found was creating a
>single view, nothing much on spawning\destroying multiple views. The view
>will be placed in my CGrapher class which extends CDockablePane.
>
>
>thanks,
>
>Nick
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm