Click here to Skip to main content
15,900,378 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Intercept a WM message into a C++ class Pin
428817-Aug-09 4:49
428817-Aug-09 4:49 
AnswerRe: Intercept a WM message into a C++ class Pin
Bacon Ultimate Cheeseburger14-Aug-09 13:07
Bacon Ultimate Cheeseburger14-Aug-09 13:07 
QuestionCan I control MyApp browser extension button order in "Internet Explorer" default toolbar after installation? Pin
neocoin13-Aug-09 8:16
neocoin13-Aug-09 8:16 
QuestionCalling a COM interface from a worker thread Pin
sashoalm13-Aug-09 6:43
sashoalm13-Aug-09 6:43 
AnswerRe: Calling a COM interface from a worker thread Pin
Stuart Dootson13-Aug-09 6:51
professionalStuart Dootson13-Aug-09 6:51 
GeneralRe: Calling a COM interface from a worker thread Pin
sashoalm13-Aug-09 20:48
sashoalm13-Aug-09 20:48 
GeneralRe: Calling a COM interface from a worker thread Pin
Stuart Dootson13-Aug-09 21:07
professionalStuart Dootson13-Aug-09 21:07 
GeneralRe: Calling a COM interface from a worker thread Pin
Stuart Dootson14-Aug-09 2:08
professionalStuart Dootson14-Aug-09 2:08 
[I could have sworn I'd posted this message before...]

I've been playing with a little Excel automation sample I've got, adding a) Word automation, and b) multi-threading to it. I've ended up with this code that a) creates a Word instance on the main thread and b) calls that Word instance on a different thread. And the call succeeds, returning the expected value!

#include <boost/thread.hpp>
#import "libid:00020905-0000-0000-C000-000000000046" version("1.6") auto_search no_dual_interfaces rename("RGB", "wordRGB") rename("ReplaceText", "wordReplaceText") rename("FindText", "wordFindText") rename("ExitWindows", "wordExitWindows")

void GetActiveDocName(Word::_ApplicationPtr const& wd, _bstr_t& name)
{
   try
   {
      name = wd->ActiveDocument->Name;
   }
   catch(_com_error& e)
   {
      name = L"No name";
   }
}

int _tmain(int argc, _TCHAR* argv[])
{
   CoInitializeEx(0, COINIT_MULTITHREADED);
   {
      Word::_ApplicationPtr wd;
      if (SUCCEEDED(wd.CreateInstance(__uuidof(Word::Application))))
      {
         // Make sure there's at least one document
         wd->Documents->Add();
         _bstr_t name;
         // Execute GetActiveDocName(wd, name) on a separate thread
         boost::thread getName(GetActiveDocName, boost::cref(wd), boost::ref(name));
         // Wait for the thread to terminate
         getName.join();
         std::cout << (char*)name << std::endl;
      }
   }
   CoUninitialize();
   return 0;
}


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

QuestionHow to log visited URLs Pin
televes13-Aug-09 5:51
televes13-Aug-09 5:51 
AnswerRe: How to log visited URLs [modified] Pin
Bacon Ultimate Cheeseburger13-Aug-09 12:12
Bacon Ultimate Cheeseburger13-Aug-09 12:12 
JokeRe: How to log visited URLs Pin
Moak13-Aug-09 13:43
Moak13-Aug-09 13:43 
GeneralRe: How to log visited URLs Pin
televes14-Aug-09 10:51
televes14-Aug-09 10:51 
AnswerRe: How to log visited URLs Pin
kilt17-Aug-09 3:36
kilt17-Aug-09 3:36 
GeneralMSI installation: problem when Norton Antivirus is active Pin
VictorSotnikov13-Aug-09 5:47
VictorSotnikov13-Aug-09 5:47 
GeneralRe: MSI installation: problem when Norton Antivirus is active Pin
Bacon Ultimate Cheeseburger13-Aug-09 16:11
Bacon Ultimate Cheeseburger13-Aug-09 16:11 
Questionrand() causing unresolved external symbol Pin
Member 321680813-Aug-09 5:05
Member 321680813-Aug-09 5:05 
AnswerRe: rand() causing unresolved external symbol Pin
Stuart Dootson13-Aug-09 5:17
professionalStuart Dootson13-Aug-09 5:17 
GeneralRe: rand() causing unresolved external symbol Pin
Member 321680813-Aug-09 5:25
Member 321680813-Aug-09 5:25 
QuestionRe: rand() causing unresolved external symbol Pin
Randor 13-Aug-09 12:56
professional Randor 13-Aug-09 12:56 
AnswerRe: rand() causing unresolved external symbol Pin
Member 321680814-Aug-09 3:27
Member 321680814-Aug-09 3:27 
QuestionWord automation question Pin
sashoalm13-Aug-09 4:54
sashoalm13-Aug-09 4:54 
AnswerRe: Word automation question Pin
Stuart Dootson13-Aug-09 5:11
professionalStuart Dootson13-Aug-09 5:11 
GeneralRe: Word automation question Pin
sashoalm13-Aug-09 5:35
sashoalm13-Aug-09 5:35 
GeneralRe: Word automation question Pin
Stuart Dootson13-Aug-09 22:17
professionalStuart Dootson13-Aug-09 22:17 
QuestionStatic pointer Pin
kumar sanghvi13-Aug-09 4:22
kumar sanghvi13-Aug-09 4:22 

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.