Click here to Skip to main content
15,889,116 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: ATL compiler error Pin
David Crow12-Mar-10 5:55
David Crow12-Mar-10 5:55 
AnswerRe: ATL compiler error Pin
Roger Stoltz12-Mar-10 8:34
Roger Stoltz12-Mar-10 8:34 
GeneralRe: ATL compiler error Pin
David Crow12-Mar-10 9:50
David Crow12-Mar-10 9:50 
GeneralRe: ATL compiler error Pin
Roger Stoltz16-Mar-10 0:34
Roger Stoltz16-Mar-10 0:34 
GeneralRe: ATL compiler error Pin
David Crow16-Mar-10 2:58
David Crow16-Mar-10 2:58 
GeneralRe: ATL compiler error Pin
Roger Stoltz16-Mar-10 4:44
Roger Stoltz16-Mar-10 4:44 
GeneralRe: ATL compiler error Pin
David Crow16-Mar-10 9:00
David Crow16-Mar-10 9:00 
GeneralRe: ATL compiler error Pin
Roger Stoltz19-Mar-10 2:30
Roger Stoltz19-Mar-10 2:30 
DavidCrow wrote:
Previously, my CMyEventHandler class was derived from, among others, IWMPEvents, and I thought I had the appropriate IWMPEvents entry in the BEGIN_COM_MAP() macro. So I don't understand what the Media Player server could have been asking for that I was not providing/exposing.


Yep, but as I understand it you got a compiler error at that time and not the runtime error that says the server cannot find the IWMPEvents interface in your client.

DavidCrow wrote:
They were added by the ATL Object Wizard.


Okay. You probably used the wizard that is used for creating COM servers. But that's a minor problem, it just made me unsure of what you were trying to do. Never mind.


DavidCrow wrote:
How does moving the IWMPEvents interface to CMyEventSink differ from having it in CMyEventHandler?


In your case it doesn't really make a difference in practice.
However, I consider the nested class a more versatile solution or design pattern. One major benefit is to avoid circular references.
Consider COM server A that creates another COM server B. A is created by the client C. B exposes a source interface, e.g. a connection point, for which A implements an event sink and register itself for receiving COM events from B. When B requests the interface for the event sink it will increment the reference of A according to COM rules.
The problem is that when C wants to destroy A by releasing its last reference, the A reference counter will not reach zero as B still holds a reference to it. This will force a kind of catch 22 situation where neither A nor B will get their last reference released.
The root cause is that both C and B uses the same object for reference counting in A. One solution is to create another object, like a nested class inside A, that serves as event sink.

My point is that if you master this way of creating an event sink, you'll probably never have to do it in another way.
I also consider it more clean from a design point of view.

"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


QuestionSystem Tray Context Menu Pin
MrMcIntyre11-Mar-10 9:09
MrMcIntyre11-Mar-10 9:09 
AnswerRe: System Tray Context Menu Pin
loyal ginger11-Mar-10 9:31
loyal ginger11-Mar-10 9:31 
GeneralRe: System Tray Context Menu Pin
MrMcIntyre11-Mar-10 9:40
MrMcIntyre11-Mar-10 9:40 
GeneralRe: System Tray Context Menu Pin
loyal ginger11-Mar-10 9:59
loyal ginger11-Mar-10 9:59 
GeneralRe: System Tray Context Menu Pin
loyal ginger11-Mar-10 10:07
loyal ginger11-Mar-10 10:07 
GeneralRe: System Tray Context Menu Pin
LouisLewis15-Mar-10 11:05
LouisLewis15-Mar-10 11:05 
AnswerRe: System Tray Context Menu Pin
David Crow11-Mar-10 10:45
David Crow11-Mar-10 10:45 
AnswerRe: System Tray Context Menu Pin
Richard MacCutchan11-Mar-10 10:51
mveRichard MacCutchan11-Mar-10 10:51 
QuestionEncoding a string Pin
Herboren11-Mar-10 8:42
Herboren11-Mar-10 8:42 
AnswerRe: Encoding a string Pin
Chris Losinger11-Mar-10 8:48
professionalChris Losinger11-Mar-10 8:48 
AnswerRe: Encoding a string Pin
Jonathan Davies11-Mar-10 8:51
Jonathan Davies11-Mar-10 8:51 
GeneralRe: Encoding a string Pin
Herboren11-Mar-10 9:01
Herboren11-Mar-10 9:01 
GeneralRe: Encoding a string Pin
Jonathan Davies11-Mar-10 9:13
Jonathan Davies11-Mar-10 9:13 
GeneralRe: Encoding a string Pin
Herboren11-Mar-10 9:29
Herboren11-Mar-10 9:29 
GeneralRe: Encoding a string Pin
Herboren11-Mar-10 9:34
Herboren11-Mar-10 9:34 
GeneralRe: Encoding a string Pin
loyal ginger11-Mar-10 9:39
loyal ginger11-Mar-10 9:39 
GeneralRe: Encoding a string [modified] Pin
Herboren11-Mar-10 9:44
Herboren11-Mar-10 9:44 

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.