From: Newsgroupie on
Hello fellow Newsgroupies,

I have a third party ActiveX control which like most ActiveX controls
insists on being created and living on a Window (whether it is visible
or not).

However, I would like to embed it as a data object somewhere using its
wrapper class and not have to create it on some transient child /
popup window. Is there anyway that I could create an instance of this
ActiveX (say as a member of a CDocument derived class) and link it
somehow to the main application window (just to keep it happy)?

I could then use it as a simple data object.

Many thanks in advance,

'Newsgroupie'
England
From: Joseph M. Newcomer on
Basically, no. As a control, it must always live as a child of another window. Putting
it in a CDocument would be meaningless. Then the problem is that even if you create it in
the "main window", you have to worry about where its notifications go, which would in this
case be to the main window.

Now, if the role of this ActiveX control is strictly document-centric, then the correct
solution is to create a top-level window in the document (this presumes the ActiveX
control is not visible!) and put the ActiveX control in that window. That window, which
is logically part of the CDocument-derived class, would receive the notifications and do
document-centric things with it.

I have no idea what a "simple data object" actually is. But you do have to ask questions
like what is the role of this control if the document is saved to a file; is the control
part of the logical file state (tricky: it has to have a serialize method!) or is it just
transient state.

What, exactly, is the problem of creating a window to hold it? There is some bizarre idea
that reusing existing objects to hold things, no matter how inappropriate, is a Good Idea
(I see this all the time with people lumping irrelevant subroutines together into util.cpp
or some such silly file instead of creating one file per subroutine or set of
closely-related subroutines).
joe

On Tue, 20 May 2008 02:25:04 -0700 (PDT), Newsgroupie <buzbymb(a)yahoo.co.uk> wrote:

>Hello fellow Newsgroupies,
>
>I have a third party ActiveX control which like most ActiveX controls
>insists on being created and living on a Window (whether it is visible
>or not).
>
>However, I would like to embed it as a data object somewhere using its
>wrapper class and not have to create it on some transient child /
>popup window. Is there anyway that I could create an instance of this
>ActiveX (say as a member of a CDocument derived class) and link it
>somehow to the main application window (just to keep it happy)?
>
>I could then use it as a simple data object.
>
>Many thanks in advance,
>
>'Newsgroupie'
>England
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Ajay Kalra on
No, you cant do this. ActiveX control is designed tohave a contract with the
container and you cant change it arbitrarily by breaking it.

--
Ajay


"Newsgroupie" <buzbymb(a)yahoo.co.uk> wrote in message
news:f476702a-ce6f-4faf-8336-87277c51f648(a)y38g2000hsy.googlegroups.com...
> Hello fellow Newsgroupies,
>
> I have a third party ActiveX control which like most ActiveX controls
> insists on being created and living on a Window (whether it is visible
> or not).
>
> However, I would like to embed it as a data object somewhere using its
> wrapper class and not have to create it on some transient child /
> popup window. Is there anyway that I could create an instance of this
> ActiveX (say as a member of a CDocument derived class) and link it
> somehow to the main application window (just to keep it happy)?
>
> I could then use it as a simple data object.
>
> Many thanks in advance,
>
> 'Newsgroupie'
> England