Re: MFC Newbie design question



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.


.



Relevant Pages

  • Re: Reading XML stream using unmanaged c++
    ... You don't need a back pointer to implement tree structures. ... but a back pointer is a handy thing to have when using a DOM node. ... XML is metadata, but an XML document is an XML metadata structure with actual data ...
    (microsoft.public.vc.mfc)
  • Re: TreeView with Recursive TreeNode....
    ... > head that he was trying to output a tree in html, ... The xml would possibly give you an advantage in already ... > "Mark Broadbent" wrote in message ... >> for mirroring this in a TreeView and this is probably correct. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: TreeView Dynamic XML Binding
    ... By monitoring the treeview child nodes when I explicitly set the XmlDataSource.DataFile, I determined that the process is actually using the PopulateOnDemand processing. ... I'm going to put the xml document into a session variable. ... It seems as if the default settings are doing the populate on expand ... otherwise the entire tree reset. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: TreeView with Recursive TreeNode....
    ... "Mark Broadbent" wrote in message ... > Whether this data is read in as XML or not, the tree would still ... > XML would be benefical). ... > for mirroring this in a TreeView and this is probably correct. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: TreeView with Recursive TreeNode....
    ... Whether this data is read in as XML or not, the tree would still have ... to be built up using traditional programming methods (message calls to the ... TreeView object) -so Im not too sure where Iain is coming from (although ...
    (microsoft.public.dotnet.framework.windowsforms)

Loading