Re: MFC Newbie design question
- From: brm@xxxxxxxxxxxxxxxxxxx (Ben)
- Date: 15 Apr 2005 05:09:43 -0700
Hi KMA,
Thanks for taking the time to reply. You're right, I don't need to
reference count it. I like the idea about a method in the Document
class that wraps up the searching/updating of the document, I guess at
the end of that update code I can call UpdateAllViews() indicating the
change in some way. Cheers ;-)
Sometimes it good to have a sanity check now and then. Thanks for the
help.
Ben.
"KMA" <KMA@xxxxxxxxxxxxxxxx> wrote in message news:<d3ljtp$t2i$1@xxxxxxxxxxxxxxxxx>...
> Ben,
>
> What you've written sounds reasonable to me. The only remark I'd make is
> that I don't think you need to store a COM pointer (to an interface) in the
> tree node. That is to say, you could simply copy the XML Node COM pointer
> without increasing the reference count. At the end of the day the tree node
> item data is just a DWORD value and requires no special treatment in itself.
>
> Then you could write a method in the doc class to that takes a DWORD and a
> new value. Call this whenever the tree value changes. This method would then
> locate the correct XML node object and update it accordingly. Naturally
> whenever you add or delete nodes you'll have to do some housekeeping on the
> tree, but at least you've removed any direct tie between the tree and the
> XML object.
>
> I hope this makes sense.
>
>
>
>
> "Ben" <brm@xxxxxxxxxxxxxxxxxxx> wrote in message
> news:cf0e12df.0504140204.168304be@xxxxxxxxxxxxxxxxxxxxx
> > Hi All,
> >
> > I'm putting together an MFC app (SDI) that allows the
> > loading/editing/saving of an XML document.
> >
> > The MSXML document will be stored as a reference in the Document
> > class.
> >
> > The loaded (XML) document will be displayed in a TreeView.
> >
> > To ease editing I was thinking about using SetItemData() to map a node
> > in the TreeView against its corresponding node in the XML document (by
> > storing a reference to the XML node against the TreeView node).
> >
> > The user can then manipulate the DOM by selecting a node in the
> > treeview, changing it's attributes etc.
> >
> > I have a slight chicken/egg problem though.
> >
> > In Document::Serialize() I need to release the existing MSXML document
> > and clear down the existing treeview BEFORE loading a new document.
> >
> > But I can't ->Release() the old MSXML document because its referenced
> > by nodes in the old tree.
> >
> > So I think i have to firstly, delete all the items in the treeview, by
> > iterating though each item, calling GetItemData(), casting it back to
> > a smart pointer, calling release on the MSXML Node (smart pointer).
> > Then call DeleteAllItems() on the TreeCtrl, then release the MSXML
> > document.
> >
> > I think I need to do this in Document::Seriliaze() prior to loading
> > the new document.
> >
> > Does this sound right?
> >
> > Many thanks in advance,
> > Ben.
.
- References:
- MFC Newbie design question
- From: Ben
- Re: MFC Newbie design question
- From: KMA
- MFC Newbie design question
- Prev by Date: Re: MFC Newbie design question
- Next by Date: List of Open Sessions
- Previous by thread: Re: MFC Newbie design question
- Next by thread: changing the application name
- Index(es):
Relevant Pages
|