Click here to Skip to main content
15,922,427 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalfrom VC++6 to C++.net Pin
Sumudu Perera9-Apr-02 6:11
Sumudu Perera9-Apr-02 6:11 
GeneralRe: from VC++6 to C++.net Pin
Rick Crone9-Apr-02 6:41
Rick Crone9-Apr-02 6:41 
GeneralRe: from VC++6 to C++.net Pin
Sumudu Perera9-Apr-02 6:44
Sumudu Perera9-Apr-02 6:44 
GeneralCSplitterWnd and CToolBar Pin
dazinith9-Apr-02 6:02
dazinith9-Apr-02 6:02 
GeneralMicrosoft Paint's toolbar. Pin
kursatkaraca9-Apr-02 5:56
kursatkaraca9-Apr-02 5:56 
GeneralAlmost gettin' mad: sockaddr_in Pin
User 66589-Apr-02 5:19
User 66589-Apr-02 5:19 
GeneralRe: Almost gettin' mad: sockaddr_in Pin
Joaquín M López Muñoz9-Apr-02 7:55
Joaquín M López Muñoz9-Apr-02 7:55 
GeneralThanks!!! Pin
User 66589-Apr-02 8:03
User 66589-Apr-02 8:03 
GeneralMultiDocument And MultView (and per document) :: MFC Pin
valikac9-Apr-02 5:05
valikac9-Apr-02 5:05 
GeneralRe: MultiDocument And MultView (and per document) :: MFC Pin
l a u r e n9-Apr-02 5:28
l a u r e n9-Apr-02 5:28 
GeneralRe: MultiDocument And MultView (and per document) :: MFC Pin
Roger Allen9-Apr-02 5:31
Roger Allen9-Apr-02 5:31 
GeneralRe: Like this? Pin
valikac9-Apr-02 16:01
valikac9-Apr-02 16:01 
GeneralRe: SDI or MDI Pin
valikac9-Apr-02 18:35
valikac9-Apr-02 18:35 
GeneralDocument View - Printing Pin
AJ1239-Apr-02 4:58
AJ1239-Apr-02 4:58 
GeneralRe: Document View - Printing Pin
Roger Allen9-Apr-02 5:28
Roger Allen9-Apr-02 5:28 
GeneralPure Virtual Functions Pin
PaulJ9-Apr-02 4:38
PaulJ9-Apr-02 4:38 
GeneralRe: Pure Virtual Functions Pin
Roger Allen9-Apr-02 4:42
Roger Allen9-Apr-02 4:42 
QuestionHow to make my window transparent while dragged (code inside) Pin
John O'Byrne9-Apr-02 4:30
John O'Byrne9-Apr-02 4:30 
AnswerRe: How to make my window transparent while dragged (code inside) Pin
Roger Allen9-Apr-02 4:46
Roger Allen9-Apr-02 4:46 
GeneralRe: How to make my window transparent while dragged (code inside) Pin
John O'Byrne9-Apr-02 4:55
John O'Byrne9-Apr-02 4:55 
GeneralRe: How to make my window transparent while dragged (code inside) Pin
Roger Allen9-Apr-02 5:20
Roger Allen9-Apr-02 5:20 
GeneralRe: How to make my window transparent while dragged (code inside) Pin
John O'Byrne9-Apr-02 5:37
John O'Byrne9-Apr-02 5:37 
General*LPUNKOWN Pin
Braulio Dez9-Apr-02 4:05
Braulio Dez9-Apr-02 4:05 
GeneralRe: *LPUNKOWN Pin
Tim Smith9-Apr-02 4:25
Tim Smith9-Apr-02 4:25 
Yes and yes. Both are correct.

Here are some general rules about addref/release. A lot of it is based on the idea of borrowing an interface and owning an interface.

1. When an interface is passed to another routine, the routine need not invoke AddRef UNLESS the interface is going to be saved and later used outside of the scope of the invocation.

The idea here is that the calling routine already owns the object (by having a ref). Thus, the routine being called temporarily borrows ownership of the object while it is executing.

2. When an interface is returned to a calling routine, the routine returning the interface MUST AddRef the object. Then when the calling routine is done with the interface he should Release unless the interface is being saved for later use.

The idea in this case is that when the routine being called returns, he must either give the ownership of the object to the calling routine (by not calling AddRef) or share ownership with himself and the caller by invoking AddRef.


You code is a perfect example of point #2. The routine being called AddRefs the object to be returned. The calling routine saves a copy of the object (which due to how CComQIPtr works also does an AddRef) and then releases the returned interface.

So after all is said and done, _pXMLClonedDoc in both objects still maintain a reference.

Tim Smith

I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
GeneralRe: *LPUNKOWN Pin
Braulio Dez9-Apr-02 4:45
Braulio Dez9-Apr-02 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.