Re: MFC Newbie design question
- From: "KMA" <KMA@xxxxxxxxxxxxxxxx>
- Date: Thu, 14 Apr 2005 13:27:33 +0200
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.
.
- Follow-Ups:
- Re: MFC Newbie design question
- From: Ben
- Re: MFC Newbie design question
- References:
- MFC Newbie design question
- From: Ben
- MFC Newbie design question
- Prev by Date: Re: MFC Newbie design question
- Next by Date: Re: changing the application name
- Previous by thread: Re: MFC Newbie design question
- Next by thread: Re: MFC Newbie design question
- Index(es):
Relevant Pages
|
Loading