MULTITHREADED apartment and ActiveX controls

I use Visual C++ 6.0 SP2.
I have multihreaded DCOM client. DCOM I initialize by CoInitializeEx(NULL, COINIT_MULTITHREADED), beacause I have a few threads from which I call objects. But now I want use some ActiveX controls in dialogs. When I try it, DoModal tries call AfxOleInit. It fails and returns RPC_E_CHANGED_MODE.
What can I do?  Can I prevent AfxOleInit call?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

anoopsConnect With a Mentor Commented:
All userinterface related stuff needs a message loop. And UI threads SHOULD be working in STA. More over ActiveX controls should also work in VB and all VB based clients work in STA.
 I guess, somewhere I had read that ActiveX controls always work in STA. Hence I guess you faced the problem because of the COINIT_MULTITHREADED flag..
If you really want multithread then you will hit a number of problems with MFC as most of it assumes single threaded apartment. I got caught by this as well when m drag-drop would not work!.  One solution may to do call couninit before DoModal
knillAuthor Commented:
Are you sure, that it is good idea? Didn't I by CoUnitialize release all object references?
BTW: I already soved this problem. I have MTA with main message loop thread and STA with second message loop thread for all dialogs with ActiveX Controls.
All Courses

From novice to tech pro — start learning today.