OCX 'InitInstance( )' recursion

OCX 'InitInstance( )' recursion

Post by Sm9ob » Sat, 01 May 2004 22:01:03


I have created an ActiveX control that I want use, in part, to encapsulate another ActiveX control.
Currently I am using the 'smart pointer' approach to loading the 'inner' control, which I do in the outer control's InitInstance( ) method. When you instantiate a smart pointer, under the covers CoCreateInstance( ) is called, which results in InitInstance being called recursively. The second time I hit the smart pointer instantiation, the system hangs up.
Is my approach to this wrong? Or, if my approach is OK, what is the standard technique to avoid executing the body of InitInstance( ) a second time? Thank you for any help.
 
 
 

OCX 'InitInstance( )' recursion

Post by Alexander » Sat, 01 May 2004 23:52:24

InitInstance is not a member of your control - it is a member
of your app class and executes within DllMain. You are prohibited
from loading DLLs and starting threads in DllMain, and that is
exactly what may happen if you call CoCreateInstance.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: XXXX@XXXXX.COM
MVP VC FAQ: http://www.yqcomputer.com/
=====================================


another ActiveX control.
control, which I do in the outer control's InitInstance( ) method. When you
instantiate a smart pointer, under the covers CoCreateInstance( ) is called,
which results in InitInstance being called recursively. The second time I
hit the smart pointer instantiation, the system hangs up.
standard technique to avoid executing the body of InitInstance( ) a second
time? Thank you for any help.

 
 
 

OCX 'InitInstance( )' recursion

Post by Sm9ob » Sun, 02 May 2004 06:21:04

Alexander
Thanks for your reply. Is creating the inner ActiveX control prohibited only is some areas of the DLL (like InitInstance( ))? Or is my entire approach doomed to fail--that is, is opening a connection with another ActiveX control from within my own possible at all? Regards
Joh




InitInstance is not a member of your control - it is a membe
of your app class and executes within DllMain. You are prohibite
from loading DLLs and starting threads in DllMain, and that i
exactly what may happen if you call CoCreateInstance

--
====================================
Alexander Nickolo
Microsoft MVP [VC], MCS
email: XXXX@XXXXX.COM
MVP VC FAQ: http://www.yqcomputer.com/
====================================
"John" < XXXX@XXXXX.COM > wrote in messag

> I have created an ActiveX control that I want use, in part, to encapsulat
another ActiveX control
> Currently I am using the 'smart pointer' approach to loading the 'inner
control, which I do in the outer control's InitInstance( ) method. When yo
instantiate a smart pointer, under the covers CoCreateInstance( ) is called
which results in InitInstance being called recursively. The second time
hit the smart pointer instantiation, the system hangs up
> Is my approach to this wrong? Or, if my approach is OK, what is th
standard technique to avoid executing the body of InitInstance( ) a secon
time? Thank you for any help
>
 
 
 

OCX 'InitInstance( )' recursion

Post by Alexander » Sun, 02 May 2004 11:57:20

Only DllMain has that limitation. You should be fine if you
do it at creation time of your control. Can't point you to the
precise place, since it's been many years since I've used
MFC... (and not for COM work anyway)

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: XXXX@XXXXX.COM
MVP VC FAQ: http://www.yqcomputer.com/
=====================================


only is some areas of the DLL (like InitInstance( ))? Or is my entire
approach doomed to fail--that is, is opening a connection with another
ActiveX control from within my own possible at all? Regards,



encapsulate
'inner'
When you
called,
time I
the
second