Re: MFC Newbie design question



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.
.



Relevant Pages

  • Re: This code demonstrates a problem using a treeview twice
    ... I know if I reinitialize the treeview it woks OK. ... But I wanted to retain the reference so that it would retain the users last ... 'Static beenHereBefore As Boolean 'Need to initialize the tree ... Private Sub Button1_Click(ByVal sender As Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Exposing contained types.. Especially LISTS
    ... Code may want to interact with A's methods (add ... the original and permanent" "holder" to the reference to TheList, ... Now one can navigate up and down the tree easily using ... This is a case where the clients now all talk to to navigate the ...
    (comp.object)
  • Re: OO Reuse
    ... >> with the topic REUSE. ... > the Treeview, other than adding gizmos like images (folders, coloured ... > - but not once did I find a reference, where having clicked on an item ... Well, Jimmy, I am reading it. ...
    (comp.lang.cobol)
  • Re: EventHandler and sender object
    ... The first argument is used to pass a reference to the same onject that is ... but the code you r writing needs to manipulate properties and members ... of another class (i.e the control or componet you are using). ... > but when I try to use any TreeView method or access any TreeView ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [PATCH] fix race in mark_mounts_for_expiry()
    ... > don't move from one tree to another (bind mounts don't link them, ... > the parents should be inaccessible anyway. ... except chroot() changes ... It would need quite a revamp of the current reference counting. ...
    (Linux-Kernel)