Click here to Skip to main content
15,913,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Color Pin
5-Nov-01 0:07
suss5-Nov-01 0:07 
GeneralSerialize problem Pin
bashi4-Nov-01 20:09
bashi4-Nov-01 20:09 
GeneralAveraging & Median Filters Pin
4-Nov-01 19:50
suss4-Nov-01 19:50 
GeneralRe: Averaging & Median Filters Pin
markkuk4-Nov-01 20:00
markkuk4-Nov-01 20:00 
QuestionBoot Disk? Pin
Stephen Caldwell4-Nov-01 18:16
Stephen Caldwell4-Nov-01 18:16 
AnswerRe: Boot Disk? Pin
markkuk4-Nov-01 20:28
markkuk4-Nov-01 20:28 
AnswerRe: Boot Disk? Pin
Jon Hulatt4-Nov-01 22:52
Jon Hulatt4-Nov-01 22:52 
GeneralVC++ Multi-Threaded Add-In... Pin
4-Nov-01 18:14
suss4-Nov-01 18:14 
Ok, I'm wanting to have VC++ go to open a file and go to a particular line in the file... the filename and line number will be sent from an *external* application.

So far, my idea was to write a VC++ add-in that opened a named pipe at waited for a message from the external app. (If someone has a better suggestion, please let me know...) Here is my problem:

In CDSAddIn::OnConnection(...), I create a new thread with AfxBeginThread(...) that makes the pipe and waits. After receiving the message, the pipe calls a new function in the CCommands class, which in turn should open the passed file and go to the line as so:


STDMETHODIMP CCommands::OpenAndGoTo(BSTR szFilename, int nLine)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

IDocuments* pDocuments = NULL;
m_pApplication->get_Documents((IDispatch**)&pDocuments);

// open the file
ITextDocument* pDoc = NULL;
CComBSTR bstrFileName = szFilename;
CComVariant vtDocType = "Text";
CComVariant vtReadOnly = FALSE;
pDocuments->Open(bstrFileName, vtDocType, vtReadOnly, (IDispatch**)&pDoc);

// TODO: go to the line number


return S_OK;
}

Everything works fine until the call to pDocuments->Open(...), which crashes with an unhandled exception: access violation error. The really weird thing is, the exact same function works perfectly fine when called from somewhere inside the main thread (i.e. if I call the function from the CDSAddIn::OnConnection(...) function, everything works perfect). It only crashes when I call the function from the created thread. Any ideas as to why?!

Thanks for your help...
~ Stevo

GeneralRe: VC++ Multi-Threaded Add-In... Pin
Jamie Hale5-Nov-01 6:18
Jamie Hale5-Nov-01 6:18 
GeneralNeed help urgently in my MCSD questions Pin
Assem Abdel Maqsoud4-Nov-01 15:58
Assem Abdel Maqsoud4-Nov-01 15:58 
GeneralRe: Need help urgently in my MCSD questions Pin
Jim A. Johnson4-Nov-01 16:41
Jim A. Johnson4-Nov-01 16:41 
GeneralRe: Need help urgently in my MCSD questions Pin
Christian Graus4-Nov-01 16:48
protectorChristian Graus4-Nov-01 16:48 
GeneralRe: Need help urgently in my MCSD questions Pin
Michael Martin4-Nov-01 17:41
professionalMichael Martin4-Nov-01 17:41 
GeneralRe: Need help urgently in my MCSD questions Pin
Christian Graus4-Nov-01 17:56
protectorChristian Graus4-Nov-01 17:56 
GeneralRe: Need help urgently in my MCSD questions Pin
Chris Maunder4-Nov-01 20:11
cofounderChris Maunder4-Nov-01 20:11 
GeneralRe: Need help urgently in my MCSD questions Pin
Nish Nishant4-Nov-01 20:25
sitebuilderNish Nishant4-Nov-01 20:25 
GeneralRe: Need help urgently in my MCSD questions Pin
Christian Graus4-Nov-01 21:58
protectorChristian Graus4-Nov-01 21:58 
GeneralRe: Need help urgently in my MCSD questions Pin
Jon Hulatt4-Nov-01 22:56
Jon Hulatt4-Nov-01 22:56 
GeneralRe: Need help urgently in my MCSD questions Pin
Chris Maunder5-Nov-01 1:39
cofounderChris Maunder5-Nov-01 1:39 
GeneralRe: Need help urgently in my MCSD questions Pin
Tomasz Sowinski5-Nov-01 1:57
Tomasz Sowinski5-Nov-01 1:57 
GeneralRe: Need help urgently in my MCSD questions Pin
Assem Abdel Maqsoud5-Nov-01 7:03
Assem Abdel Maqsoud5-Nov-01 7:03 
GeneralRe: Need help urgently in my MCSD questions Pin
Not Active5-Nov-01 2:20
mentorNot Active5-Nov-01 2:20 
GeneralRe: Need help urgently in my MCSD questions Pin
5-Nov-01 7:11
suss5-Nov-01 7:11 
GeneralRe: Need help urgently in my MCSD questions Pin
5-Nov-01 7:11
suss5-Nov-01 7:11 
GeneralRe: Need help urgently in my MCSD questions Pin
Christian Graus5-Nov-01 8:44
protectorChristian Graus5-Nov-01 8: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.