×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Creating An OCX On The Fly?

Creating An OCX On The Fly?

Creating An OCX On The Fly?

(OP)
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?

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...

Is it anything to do with CoCreateInstance()? If so, how do I specify its parent window? Questions, questions...

RE: Creating An OCX On The Fly?

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.

Karl
kb244@kb244.8m.com

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)

RE: Creating An OCX On The Fly?

(OP)
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.

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.

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.

I hope that makes it clearer what I would like to achieve.



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 "version number in the type library was incorrect". 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.

What did I miss?


RE: Creating An OCX On The Fly?

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.

Karl
kb244@kb244.8m.com

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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close