Reloading an ActiveX control

I have an ATL ActiveX control that works, but it's crashing every time I hit reload because the software doesn't appear to exit entirly before running through the initalization again.

The WM_DESTROY event runs, but it imidatly starts up with WM_INITDIALOG again before quitting.

How do I make the plugin fully exit, and then re-launch when the user hits reload in the browser?
LVL 5
GENTPAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dariusz DziaraProgrammerCommented:
I am a little bit confused.

1. "How do I make the plugin fully exit, and then re-launch when the user hits reload in the browser?" - do you use the control on some web page ?

2. Or maybe in dialog - "WM_INITDIALOG" ?

If you use different control will everything be OK ?
MechanTOurSCommented:
U must make sure u destroy ur control correctly

1) check/debug your main ATL class destructor.
u may be doing something wrong there.

2) if u have threads running, make sure to stop them.

3) unload loaded DLLs

4) do u implement InPlaceActivate & InPlaceDeactivate method ?
see IOleInPlaceObjectWindowlessImpl && CComControlBase for details

exemple:

HRESULT InPlaceActivate(LONG iVerb, const RECT* prcPosRect = NULL)
{
      return CComControlBase::InPlaceActivate(iVerb, prcPosRect);
}

HRESULT InPlaceDeactivate(void)
{      
       // u may closeThreads here
      return IOleInPlaceObjectWindowlessImpl<CUrClassControl>::InPlaceDeactivate();
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GENTPAuthor Commented:
I'm still trying to figure out how to do suggestions 1, 2, and 3.  Can you possibly help me out further with them?  4 on the other hand gives me errors when I try to add the functions you suggested.

error C2695: 'Cax3DPlugin::InPlaceDeactivate': overriding virtual function differs from 'ATL::IOleInPlaceObjectWindowlessImpl<T>::InPlaceDeactivate' only by calling convention

Now I did try calling InPlaceDeactivate(); in my WM_DESTROY function, but that didn't seem to work either.  It still doesn't cause the software to fully exit and re-launch.
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

MechanTOurSCommented:
1) do u know how to debug ur activeX ?
u need to place a breakpoint at the start of ur destructor,
then iterate each line with F10 until a line make ur activeX crash.
To enter a function call, press F11

2) are u running threads made with CreateThread function ?
if no, u shouldn't care about that one.

3) are u loading libraries with LoadLibrary function ?
if no, all is ok.

4) correction :

u should have in ur header :
STDMETHOD(InPlaceDeactivate)(void);

and in ur cpp file :
STDMETHODIMP Cax3DPlugin::InPlaceDeactivate(void)
{      
      return IOleInPlaceObjectWindowlessImpl<Cax3DPlugin>::InPlaceDeactivate();
}


u may debug / trace this line too


 
GENTPAuthor Commented:
1) yeah I know that much
2) I wasn't sure.  I'm converting a large code base and it looks like there are threads, but they're all handled properly.
3) Yes that is happening.  If things are working right now, would they be leaking?
4) InPlaceDeactivate doesn't seem to change anything.
MechanTOurSCommented:
ok, try to disable/enable ur code incrementally.

- disable all but activeX base
- check it runs and quits normally
- then activate little part or level of ur code and check it runs and quits ok.

I can't tell u more without ur whole source project.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Components

From novice to tech pro — start learning today.