Click here to Skip to main content
15,896,606 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionglDrawPixels help Pin
Member 33753342-Apr-09 12:39
Member 33753342-Apr-09 12:39 
AnswerRe: glDrawPixels help Pin
Cedric Moonen2-Apr-09 20:16
Cedric Moonen2-Apr-09 20:16 
GeneralRe: glDrawPixels help Pin
Member 33753343-Apr-09 3:05
Member 33753343-Apr-09 3:05 
QuestionNtfsDisable8dot3NameCreation does not take its effect for short path generation Pin
tom groezer2-Apr-09 10:13
tom groezer2-Apr-09 10:13 
AnswerRe: NtfsDisable8dot3NameCreation does not take its effect for short path generation Pin
tom groezer3-Apr-09 1:19
tom groezer3-Apr-09 1:19 
QuestionRaise thread safe event Pin
tadams11382-Apr-09 9:56
tadams11382-Apr-09 9:56 
AnswerRe: Raise thread safe event Pin
tadams11382-Apr-09 11:24
tadams11382-Apr-09 11:24 
AnswerRe: Raise thread safe event Pin
Roger Stoltz2-Apr-09 11:58
Roger Stoltz2-Apr-09 11:58 
tadams1138 wrote:
does anyone know the best way in an MFC ActiveX control to raise an event on another thread?


There's only one correct way, even though it may look differently depending on the implementation: marshalling.

"Raising an event" in fact means calling an interface implemented by the client from the server. The same rules apply as when calling an interface implemented by the server from a client.
As always, when crossing apartment boundaries you have to marshal the interface. Since the secondary thread in your case is another apartment, you have to marshal the client interface to the secondary apartment.
You also have to make sure you set up the secondary apartment properly by calling ::CoInitialize() from that thread before doing any COM related stuff and consequently call ::CoUninitialize() before exiting the thread.

Marshalling the client interface, or the "event sink", can be done using the GIT (Global Interface Table). You add an interface to the GIT that you want to marshal and get it in the apartment where you want to use it. When you're done with the interface you revoke it from the GIT.
Read more about the GIT here[^].


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


QuestionHow To Import and use Com file in c++ Pin
snouto2-Apr-09 7:34
snouto2-Apr-09 7:34 
AnswerRe: How To Import and use Com file in c++ Pin
CPallini2-Apr-09 7:44
mveCPallini2-Apr-09 7:44 
JokeRe: How To Import and use Com file in c++ Pin
Stuart Dootson2-Apr-09 7:48
professionalStuart Dootson2-Apr-09 7:48 
JokeRe: How To Import and use Com file in c++ Pin
CPallini2-Apr-09 7:59
mveCPallini2-Apr-09 7:59 
AnswerRe: How To Import and use Com file in c++ Pin
Iain Clarke, Warrior Programmer2-Apr-09 8:16
Iain Clarke, Warrior Programmer2-Apr-09 8:16 
QuestionDeleting the Main Window Pin
BobInNJ2-Apr-09 6:10
BobInNJ2-Apr-09 6:10 
AnswerRe: Deleting the Main Window Pin
Stuart Dootson2-Apr-09 7:17
professionalStuart Dootson2-Apr-09 7:17 
AnswerRe: Deleting the Main Window Pin
Iain Clarke, Warrior Programmer2-Apr-09 8:19
Iain Clarke, Warrior Programmer2-Apr-09 8:19 
AnswerRe: Deleting the Main Window Pin
Stuart Dootson2-Apr-09 11:26
professionalStuart Dootson2-Apr-09 11:26 
QuestionRTD in MFC application Pin
trioum2-Apr-09 4:34
trioum2-Apr-09 4:34 
AnswerRe: RTD in MFC application Pin
led mike2-Apr-09 4:46
led mike2-Apr-09 4:46 
GeneralRe: RTD in MFC application Pin
trioum2-Apr-09 4:57
trioum2-Apr-09 4:57 
QuestionRe: RTD in MFC application Pin
led mike2-Apr-09 8:17
led mike2-Apr-09 8:17 
GeneralRe: RTD in MFC application Pin
CPallini2-Apr-09 9:33
mveCPallini2-Apr-09 9:33 
QuestionRe: RTD in MFC application Pin
David Crow2-Apr-09 5:20
David Crow2-Apr-09 5:20 
AnswerRe: RTD in MFC application Pin
trioum2-Apr-09 5:25
trioum2-Apr-09 5:25 
QuestionRe: RTD in MFC application Pin
David Crow2-Apr-09 5:28
David Crow2-Apr-09 5:28 

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.