Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating An OCX On The Fly?

Status
Not open for further replies.

JTeagle

Programmer
May 30, 2000
49
GB
If I insert an ActiveX / OCX on a form at design time and add a member variable of that type using ClassWizard, all is well and I can use that object quite happily. But how can I create an instance of that OCX wrapper class on the fly? <br><br>For example, if I wanted to create a different type of OCX depending on a choice from a menu, how do I go about that? I'm almost certain that constructing the object using the generated wrapper class is not good enough. I assume I need to still generate the wrapper class first, but I don't know where to go next...<br><br>Is it anything to do with CoCreateInstance()? If so, how do I specify its parent window? Questions, questions...<br><br>
 
IF i am not mistaken, you can find somewhere in VC++ where it says add Com Wraper, or something like that, works best if its a ActiveX dll, it'll create a class for ya, that has all the same commands of the activeX. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Yes, a topic along those lines exists, but the details in it assume you are inserting the control on a form at design time, which is not what I want to do. I can do that bit already.<br><br>I would like to be able to create an instance of an ActiveX MYSELF, at run time, i.e., perform similar steps to the API when it creates the control automatically on a dialogue.<br><br>It's all very well placing controls at design time, but if you want to be able to have controls based on user choice at run time, you would have to make assumptions about what types and how many they are likely to want - not very flexible really.<br><br>I hope that makes it clearer what I would like to achieve.<br><br><br><br>By the way, this reminds me of another problem: I used VC++ to create an OCX, very simple - one method. When I tried to access it (the OCX fileitself) via the [VC++] Component and Control Gallery, it coughed up and complained that it had not been properly registered or the &quot;version number in the type library was incorrect&quot;. However, it MUST have been registered correctly, because I was able to add it to a VB project and use it quite happily before trying through the gallery.<br><br>What did I miss?<br><br><br>
 
In visual basic, and VBscript(on Active Server Page) there is a command called CreateObject, this will create an instance of an activeX control at runtime, this is also known as Late Binding. maybe VC++ has something similar. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top