ActiveX Event causes VB compiled apps to crash 
Author Message
 ActiveX Event causes VB compiled apps to crash

I have an MFC ActiveX Appwizard generated control that I use in some VB
applications. This control fires some methods and some events to 'talk' with
the VB application.

The problem arises when I send the event via Fire_XXX_Event() function from
a thread created within the control, to the VB app. If the VB app is
compiled to .EXE (if and only if compiled to .EXE) and executed, the Event
causes the app to crash.

Why? And how do I solve this?

Here it is the pseudo code that causes the VB app to crash...

// The thread class

...

CThreadThatSendAnEvent::SetOlePtr(CMyControlCtl* pOle) {
    m_pOle = pOle;

Quote:
}

CThreadThatSendAnEvent::Run()
{
    m_pOle->FireAnEventToCallerApp();
    return 0;

Quote:
}

...

// The control class

...

CMyControlCtl::SendEventToCallerApp()
{
    FireAnEventToCallerApp();    // <- This works fine, obviously...

    CThreadThatSendAnEvent* p = (CThreadThatSendAnEvent*)
        AfxBeginThread(RUNTIME_CLASS(CThreadThatSendAnEvent),
                                    THREAD_PRIORITY_NORMAL, 0,
                                    CREATE_SUSPENDED, NULL );
    p->SetOlePtr(this);
    p->ResumeThread();    // <- This causes the
CThreadThatSendAnEvent::Run()
                                        // to be called and VB app to
crash...

Quote:
}

...

Thanks.



Sat, 05 Mar 2005 22:50:14 GMT  
 ActiveX Event causes VB compiled apps to crash
See http://www.mvps.org/vcfaq/com/1.htm
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> I have an MFC ActiveX Appwizard generated control that I use in some
VB
> applications. This control fires some methods and some events to
'talk' with
> the VB application.

> The problem arises when I send the event via Fire_XXX_Event() function
from
> a thread created within the control, to the VB app. If the VB app is
> compiled to .EXE (if and only if compiled to .EXE) and executed, the
Event
> causes the app to crash.

> Why? And how do I solve this?

> Here it is the pseudo code that causes the VB app to crash...

> // The thread class

> ...

> CThreadThatSendAnEvent::SetOlePtr(CMyControlCtl* pOle) {
>     m_pOle = pOle;
> }

> CThreadThatSendAnEvent::Run()
> {
>     m_pOle->FireAnEventToCallerApp();
>     return 0;
> }

> ...

> // The control class

> ...

> CMyControlCtl::SendEventToCallerApp()
> {
>     FireAnEventToCallerApp();    // <- This works fine, obviously...

>     CThreadThatSendAnEvent* p = (CThreadThatSendAnEvent*)
>         AfxBeginThread(RUNTIME_CLASS(CThreadThatSendAnEvent),
>                                     THREAD_PRIORITY_NORMAL, 0,
>                                     CREATE_SUSPENDED, NULL );
>     p->SetOlePtr(this);
>     p->ResumeThread();    // <- This causes the
> CThreadThatSendAnEvent::Run()
>                                         // to be called and VB app to
> crash...
> }

> ...

> Thanks.



Sat, 05 Mar 2005 23:08:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Compiling atl component in VB is causing crash

2. VC++ Dll causes VB App to crash every 2nd run

3. ATL DLL event sink with a VB ActiveX DLL event source

4. ATL virtual destructor and events causes crash

5. _ATL_DEBUG_INTERFACES causes crashes when hooking up events

6. VB causes my MFC application to crash in ExitProcess

7. PeekMessage causes app to crash when it loses focus

8. pressing iPAQ cursor button with MFC Pocket PC app causes crash

9. VB.NET crashing from my com server events

10. VB APP crashes ....help

11. How to catch events fired by VB-written ActiveX DLL in VC++ client

12. Handling Events From VB ActiveX exe

 

 
Powered by phpBB® Forum Software