MFC Extension DLL with OLE

I am building dialog based Dynamic Link Library.  In the dialog there are some ActiveX controls.  Everytime I call a function which is refering some of the ActiveX controls I got some assertion failure saying that the m_CtrlSite is NULL.  Please help solve this probelm.



Regards

S. Sun.
shaozhuangAsked:
Who is Participating?
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.

galkinCommented:
If you are building shared DLL did you call AgxOleInit and AfxEnableControlContainer from DLL's InitInstance? If you are building MFC extension DLL you must call these two function insede application's InitInstance
0
shaozhuangAuthor Commented:
I checked  Galkin idea, it did not work. I also tried using AfxLockOleControl(), it did not work either.  There are must be some ways to do it.  Could somebody help?

Regards

S.Sun
0
galkinCommented:
Could you post a piece of code how you create ActiveX controls
0
shaozhuangAuthor Commented:
Hi galkin: Thanks for the help.  The ActiveX controls reside in the dialog and I asign(using calsswizard) a name for it.  In my code I call this name for some of the subroutines. WHen I call it, it give me an error saying that the m_CtrlSIte is NULL.  Do you think I need to implement a subroutine to initialize the DLL(even I use implicit initialization.

Thanks again

S. Sun

0
galkinCommented:
m_pCtrlSite is a member of CWnd class that is wrapper of ActiveX control. When control is created using by CreateControl function or from dialog template this member becomes not NULL. If creating control failed this member remains NULL. Your probelm I guess is that your ActiveX control(s) failed to be created by some reason. Check it. Enable OLE tracing and see output.  
0

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
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
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.