Create an ActiveX from inside another ActiveX 
Author Message
 Create an ActiveX from inside another ActiveX

I have 2 ActiveX (built with VC5). They both don't have an interface. In one
of them I want to create an instance of the other:

AX1:
...
AX2 * pAx2 = new AX2;
pAx2->Create(...);
...

When I call "Create" for my second ActiveX I must give a handle to the
parent that must be a "CWnd*" and I don't which object to specify. I can't
use "this" nor "this->GetParent()" etc...

Does anybody know how to do that ???

--
Remove ".net" from my email address to contact me.



Sat, 27 Apr 2002 03:00:00 GMT  
 Create an ActiveX from inside another ActiveX
Do a GetSafeHwnd() and wrap it with a  CWnd* (using Attach). And pass
that..
Oh BTW: All Activex controls do expose an interface even though they
might not have any methods in them..
On Tue, 9 Nov 1999 13:16:09 +0100, Philippe Mermoud

Quote:

>I have 2 ActiveX (built with VC5). They both don't have an interface. In one
>of them I want to create an instance of the other:

>AX1:
>...
>AX2 * pAx2 = new AX2;
>pAx2->Create(...);
>...

>When I call "Create" for my second ActiveX I must give a handle to the
>parent that must be a "CWnd*" and I don't which object to specify. I can't
>use "this" nor "this->GetParent()" etc...

>Does anybody know how to do that ???

>--
>Remove ".net" from my email address to contact me.

--
Girish Bharadwaj [mvp]


Sat, 27 Apr 2002 03:00:00 GMT  
 Create an ActiveX from inside another ActiveX
Hi,

If u call Create() it wont work... U have to call CreateControl with the
appropriate CLSID

Plus, if both controls are in the same MFC module, it cannot be done.

--
Shahar Prish
Maximal Innovative Intelligence
http://www.maxsw.com
"Computers are useless, they can only give you answers" (Pablo Picasso)
---

Quote:
> I have 2 ActiveX (built with VC5). They both don't have an interface. In
one
> of them I want to create an instance of the other:

> AX1:
> ...
> AX2 * pAx2 = new AX2;
> pAx2->Create(...);
> ...

> When I call "Create" for my second ActiveX I must give a handle to the
> parent that must be a "CWnd*" and I don't which object to specify. I can't
> use "this" nor "this->GetParent()" etc...

> Does anybody know how to do that ???

> --
> Remove ".net" from my email address to contact me.



Sat, 27 Apr 2002 03:00:00 GMT  
 Create an ActiveX from inside another ActiveX

Quote:

>Do a GetSafeHwnd() and wrap it with a  CWnd* (using Attach). And pass
>that..
>Oh BTW: All Activex controls do expose an interface even though they
>might not have any methods in them..

I know about that but I can't seem to be able to get a CWnd* right.
Both ActiveX have been created using VC5 (using MFC). My first ActiveX has
been instantiated by a delphi application. It sometimes need to instantiate
the second one and at that point I can't get a CWnd* right. The first
ActiveX has no m_hWnd (GetSafeHwnd() returns NULL) and I checked in the
de{*filter*} I've got nothing in the OleControl interface.

I tried using AfxGetMainWindow() but it also didn't give me a right
response.

--
Remove ".net" from my email address to contact me.



Sun, 28 Apr 2002 03:00:00 GMT  
 Create an ActiveX from inside another ActiveX

Quote:

>Hi,

>If u call Create() it wont work... U have to call CreateControl with the
>appropriate CLSID

Does it mean the first ActiveX must be able to contain other controls (I
don't remember the OLEMISC flag to use but I'll find out) ?

Quote:
>Plus, if both controls are in the same MFC module, it cannot be done.

What do you mean by the same MFC module ? They are 2 different OCX files. If
that's what youmean they aren't in the same module. The problem comes from
the fact that I can't get a CWnd* right (please refer to my other post in
the same thread).

--
Remove ".net" from my email address to contact me.



Sun, 28 Apr 2002 03:00:00 GMT  
 Create an ActiveX from inside another ActiveX
Shahar

What I mean by same module is the same OCX, so ur ok there...

To allow a control to create and contain other controls, u have to call
AfxEnableControlContainer() in the constructor of the control..

What u do then, is declare a new CWnd and call it's CreateControl() method.

--
Shahar Prish
Maximal Innovative Intelligence
http://www.maxsw.com
"Computers are useless, they can only give you answers" (Pablo Picasso)
---

Quote:

> >Hi,

> >If u call Create() it wont work... U have to call CreateControl with the
> >appropriate CLSID

> Does it mean the first ActiveX must be able to contain other controls (I
> don't remember the OLEMISC flag to use but I'll find out) ?

> >Plus, if both controls are in the same MFC module, it cannot be done.

> What do you mean by the same MFC module ? They are 2 different OCX files.
If
> that's what youmean they aren't in the same module. The problem comes from
> the fact that I can't get a CWnd* right (please refer to my other post in
> the same thread).

> --
> Remove ".net" from my email address to contact me.



Sun, 28 Apr 2002 03:00:00 GMT  
 Create an ActiveX from inside another ActiveX

Quote:

>Shahar

>What I mean by same module is the same OCX, so ur ok there...

>To allow a control to create and contain other controls, u have to call
>AfxEnableControlContainer() in the constructor of the control..

>What u do then, is declare a new CWnd and call it's CreateControl() method.

Thank you... I had forgotten to call AfxEnableControlContainer and the
CreateControl function worked perfectly.

--
Remove ".net" from my email address to contact me.



Sun, 28 Apr 2002 03:00:00 GMT  
 Create an ActiveX from inside another ActiveX
Much obliged.

--
Shahar Prish
Maximal Innovative Intelligence
http://www.maxsw.com
"Computers are useless, they can only give you answers" (Pablo Picasso)
---

Quote:

> >Shahar

> >What I mean by same module is the same OCX, so ur ok there...

> >To allow a control to create and contain other controls, u have to call
> >AfxEnableControlContainer() in the constructor of the control..

> >What u do then, is declare a new CWnd and call it's CreateControl()
method.

> Thank you... I had forgotten to call AfxEnableControlContainer and the
> CreateControl function worked perfectly.

> --
> Remove ".net" from my email address to contact me.



Sun, 28 Apr 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Creating ActiveX inside of another ActiveX

2. ActiveX control inside another activex control

3. ActiveX inside ActiveX

4. ActiveX inside ActiveX

5. ActiveX control inside another ActiveX control

6. Retrieve ActiveX inside an ActiveX

7. ActiveX-control inside ActiveX-control

8. Newbie question on ActiveX creating ActiveX

9. Creating ActiveX control with parent as another ActiveX

10. Creating ActiveX control with parent as another ActiveX

11. ActiveX...ActiveX...GreenTree DataList...ActiveX

12. Create ActiveX Control at runtime inside ActiveX Control, how to handle event(s)?

 

 
Powered by phpBB® Forum Software