Click to See Complete Forum and Search --> : Can't put OLE Container in UserControl OCX?


HAL-9000
September 20th, 2001, 03:42 PM
Hi all,
I'm trying to add some interoperability bettween a VC++ ActiveX controll I've created, and a VB GUI that I have. I'm not experienced in VB so I might be using the wrong approach.

My situation is such:
I have an very simple ActiveX object I have created in VC.
I have a VB GUI EXE that relies upon many other VB OCX's and C++ COM components. The user selects to see a sporting event from our website ( hockey, football, etc..), and the sport is loaded and displayed. There is a main ExpandoBtn controll (VB OCX) that manages the display and hiding of the button controls themselves. My button controls must be able to adapt to show different buttons depending on the sport, but there is no way to know what sport the user will select (currently we use a button OCX wich is a set of generic buttons that apply to most sports).

What I'm trying to achieve:
I want the ability to load, at run-time, an ActiveX controll representing the buttons we want to use. I can't compile the EXE with the buttons as a component because I don't know what buttons we will want in the future, and I don't want the user to constantly have to upgrade his EXE. I want to be able to just send the user new control objects, and have the GUI create the apropriate buttons from a ProgID I pass in.

I tried using CreateObject, it worked but I couldn't figure out what to do with the object pointer after that, i couldn't figure out how to get my ActiveX object to appear on the screen.

So, I figured I could use an OLE container object, and use the "CreateEmbed" method to create, at run time, whatever button control that would match up to the users selection. The ProgID for the controll is passed into the VB from another COM object, so the VB doesn't have to be aware of the different controlls, they just have to be registered on the machine.

My Problem:
I was able to create an OLE container object on the main form, pass in a ProgID to CreateEmbed, create the object, and have it draw into the OLE Container object just fine. But, I don't want this object on the main form. The ActiveX control is supposed to be used as a controll inside of my ExpandoBtn control. But, VB won't let me put an OLE containter control inside of my ExpandoBtn control, it gives me the following error:

"The OLE Client control and OLE embeddings are not allowed on UserControls, UserDocuments, or PropertyPages"

This UserControll contains other OCX controls, so I know it must be possible to nest objects like that. I can add my ActiveX control through the "References" dialog box and draw my ActiveX control directly, but that defeats the purpose, I couldn't load any arbitrary ActiveX control in the future without recompiling the EXE. How do I get around this restriction of not being able to draw an OLE container on my Control?

Is there a way to get my ActiveX controll to appear on the screen other than using the OLE Container?

I have scoured all of the newsgroups and the MSDN site for a way to get aroudn this, but they all describe ways to add ActiveX controls that are compiled directly into the EXE, not how to load ActiveX components at Runtime with late-binding.

Thanks for your time,
Aaron








"No representation is made that the information or opinions contained in this messages are greater than thoes provided by other messages."