Discussion:
Using an OCX control under Visual C++ 6.0
(too old to reply)
Storm
2004-06-29 14:23:22 UTC
Permalink
Hello,

First I apologize if this is the wrong newsgroup, please redirect me
to the appropriate one if this is the case.

I have a Visual C++ 6.0 application that creates the main window
dynamically (it's not MFC, it uses standard Win32 calls).
I also have an OCX control that is used to skin an application (named
ActiveSkin).

My problem is that I have instructions on how to add this OCX control
if I have a main window inside the dialog editor, but main window is
created at runtime with CreateWindowEx.

One thing that I tought about was to create a dummy window in the
dialog editor and then have the previos main window be a child of this
one, but it feels wrong.

The right way would be if I could somehow init the ocx and attach it
to the main window after this one is dynamically created.

Any kind soul could help me on this ?

Thanks in advance,
Andrei

P.S. : here are the instructions that I have on how to install the ocx
control to a form :

===================== QUOTE =================================

To insert ActiveSkin's Skin control into the form, open the form in
dialog editor, right-click it and click "Insert ActiveX Control..."
menu item. Choose "ActiveSkin Control" from the available controls
list. Of course, AfxOleInit() and AfxEnableControlContainer()
functions should be called in InitInstance() method prior using any
OLE controls.

To access the control in runtime, import its type library first:

#import "actskin4.ocx" no_implementation raw_interfaces_only
raw_native_types
using ACTIVESKINLib;

Now you can query the Skin's control interface from the form:

CComQIPtr<ISkin> pSkin; // A smart pointer to the Skin component

pSkin = GetDlgItem(IDC_SKIN)->GetControlUnknown(); // Gets the ISkin
interface of the IDC_SKIN control

Now you can apply the skin, stored in resources, or load it from the
file and manipulate the skin in other ways.

Note: never use "Project->Add To Project->Components and Controls..."
menu item. The class wrappers created by this wizard can't be used
with ActiveSkin.

===================== END OF QUOTE ==============================
Frank Renner
2004-06-29 20:55:45 UTC
Permalink
Post by Storm
My problem is that I have instructions on how to add this OCX control
if I have a main window inside the dialog editor, but main window is
created at runtime with CreateWindowEx.
Win32 API does not provide ActiveX Control hosting functionality. Even if you create
a dialog resource containing an ActiveX Control the Win32 API functions are not able
to deal with it directly. Instead class libraries that are able to handle ActiveX Controls
in dialog resources (like e.g. MFC and ATL) first replace the ActiveX Control entries
in the dialog resource by host window entries, then pass the modified dialog resource
to the Win32 API functions and finally create the ActiveX Controls attaching them to
the host windows. These host windows provide some very special ActiveX Control
containment implementation. Again this implementation is not part of the Win32 API
but the class library.

Effectively this means there is no easy way to integrate ActiveX Controls without the
help of a class library.
Post by Storm
To insert ActiveSkin's Skin control into the form, open the form in
dialog editor, right-click it and click "Insert ActiveX Control..."
menu item. Choose "ActiveSkin Control" from the available controls
list. Of course, AfxOleInit() and AfxEnableControlContainer()
functions should be called in InitInstance() method prior using any
OLE controls.
As you might have noted already AfxOleInit and AfxEnableControlContainer are
MFC functions. These functions deal with ActiveX in general and ActiveX Control
hosting in particular. The message is: use MFC (or some other class library providing
ActiveX Control containment) to integrate the Skin control.

Regards,
Frank

Loading...