Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MFC Container Dialog for a Windowless ActiveX Control

130 views
Skip to first unread message

Peter Mac Neil

unread,
Jan 13, 2003, 3:39:16 PM1/13/03
to

I'm a bit new to ActiveX controls and I have been
searching for some time for an answer.

MY problem is creating a simple dialog based
container application with VS C++ 6 that will support a
windowless control.

I created a very simple control with the AppWizzard
which is windowless when inserted into Microsoft's
ActiveX Control Test Container. When I insert that
same control into my simple dialog created again with
the AppWizzard the control is instanciated with a
window. I used Spy++ to test for the existence of a
window.
How do I convince a simple MFC dialog to instanciate
an ActiveX control windowless?

Thanks,
Peter Mac Neil

karl

unread,
Jan 13, 2003, 4:26:27 PM1/13/03
to
Why can't you create an OnInitDialog event handler and inside
CMyDialog::OnInitDialog
instruct the ActiveX control to hide its window?


"Peter Mac Neil" <pe...@screentime.com> wrote in message
news:7ebb01c2bb43$d6e6fb60$8bf82ecf@TK2MSFTNGXA05...

Rob

unread,
Jan 13, 2003, 3:57:10 PM1/13/03
to
Most likely the window you are seeing through Spy++ is the window of the
container. The standard MFC containment probably creates a window the size
of the user defined rectangle on the dialog box. The MFC containment then
instantiates your control within this container. The MFC dialog box itself
is not the container. This is how containment works within VB forms so I
would guess the same is true with MFC dialog boxes given your description.

Rob

"Peter Mac Neil" <pe...@screentime.com> wrote in message
news:7ebb01c2bb43$d6e6fb60$8bf82ecf@TK2MSFTNGXA05...

Peter Mac Neil

unread,
Jan 14, 2003, 5:30:32 PM1/14/03
to
In VC++ the container does not have to create a window
the size of the control. The MSDN documentation suggests
that creating windowless controls saves the overhead of
having a window for each control and allows non-rectangular
controls.

Microsoft's ActiveX Control Test Container hosts my simple
control witout a window the same size as my control.

Any other ideas?

Thanks,
Pete
---------
> Rob at r...@dptechnology.com wrote on 1/13/03 12:57 PM:

Rob

unread,
Jan 14, 2003, 8:38:18 PM1/14/03
to
Peter,

I'm sorry but you are mistaken. If you want to know how ActiveX control
containment works in MFC, please reference the ATL implementation of
CAxHostWindow. I know this code well since I've been developing a custom
container for our application.

The way MFC dialogs host windowless ActiveX controls is they create a window
the size of your windowless control. If the window wasn't the same size
then they wouldn't be able to handle the mouse over events properly.

Understand, the target of mouse message is dependent on whether the mouse
position is within the window's rectangle. The term windowless does not
mean that there is no window at all.

The reason Microsoft created the windowless control framework was because
previously control containment actually required two windows. The window of
the container plus the window of the control itself. Now with windowless
controls, the control can share the window of the container.

Rob

"Peter Mac Neil" <pe...@screentime.com> wrote in message

news:BA49CF88.B09%pe...@screentime.com...

Rob

unread,
Jan 14, 2003, 9:51:50 PM1/14/03
to
Peter,

If I can add just one more thing. I think the confusion here is that you
believe that the dialog box itself is a container. The truth is that the
dialog box is not a container. What an MFC dialog box does to contain
ActiveX controls is it creates a "host window" for each ActiveX control that
it parents. It's the "host window" that is the container.

I realize that the framework provides the ability to host multiple controls
within a container, however Microsoft's implementation of the "host window"
only supports one control. To the dialog box, the "host window" looks like
any other common control, ie. button, combobox, editbox. Only the "host
window" knows that there is an ActiveX control being instantiated.

Again, as I stated in my previous posting, if you investigate the
implementation of the CAxHostWindow template in the ATL you'll understand
better how this containment works.

Rob

"Rob" <r...@dptechnology.com> wrote in message
news:#mKP3aDvCHA.2488@TK2MSFTNGP12...

0 new messages