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 instance of an ActiveX control 2

Status
Not open for further replies.

rds747

Technical User
Mar 8, 2005
180
US
In a module I need to create instances of the imgedit, imgscan, and imgadmin controls.

Problem is that I cannot set new instances of the 3 controls.

my code is:

Dim objImgScan As ImgScan
Dim objImgAdmin As ImgAdmin
Dim objImgEdit As ImgEdit

The intellisense shows imgscan, imgadmin, imgedit

But I cannot set an instance of objimgscan to imgscan. So Set objimgscan = new imgscan doesn't work because the intellisense doesn't show imgscan.

Any suggestions?
 
Not all controls can be instantiated this way. In fact those that can tend to be in the minority.
 
What would be the solution for this then? Do I have to have these controls on a form and not a module?

If you get a chance can you reply to thread222-1251515(vars:global or parameters)?

Thanks.
 
What determines if a control can be instantiated or not?
 
When you want to instantiate controls, normally you will put an invisible one on your form with the index property set to 0. Then, the first time you "instantiate" the control, you'll just make it visible. To add more controls, use the load command.

HTH

Bob
 
What I would like to do is add the subs into a module so the mod could be included in any project.

In order to do that would I have to create a "dummy" form for each project that I want to use the ActiveX controls and set the visibility to false?
 
I've lost you completely, so help me out here. The way to include activex controls in a project is to compile them into an .ocx file and then select that file from the components menu, just as you would with any other control. Why aren't you doing it this way? Also, what are "the subs"? If you just have subs, and no visual interface, you shouldn't be using an activex control. Can you verify for me that your controls are part of a ui?

Thanks,

Bob
 
I'm using ocxs that are already included in windows. I was asked to create a module that can be included in any project so I wanted to figure out how to instantiate the Image controls. But I could probably just include that form in any project instead of the module.

The subs are using the properties of the Image controls.

The controls are included on the form, but they don't have any user interaction so I thought I could include instantiate the controls and include them in a module.

Hope this makes it more clear. If not please let me know how I can make it more clear.

Thanks.
 
>I'm using ocxs that are already included in windows

Sadly not, actually. Microsoft discontinued them as an OS component some years ago, and they do NOT appear in XP or Windows 2003. And the controls are unfortunately not legally redistributable.

Here's a link to the people that took over the controls:
 
Sorry I meant that I didn't have to compile these ocxs as they were already on the PC.

Wonder why Kodak sold these controls..but thats another story
 
Why are they controls and not classes? I haven't got quite clear on that yet.
 
Bob,

Not sure what you're asking for. I'm using Kodak image controls and wanted to know if I could instantiate them.
 
I see. Some controls, as strongm says, can be instantiated in the same way that classes are, but not many. Controls are in fact instantiated, but this is done by the fact of placing them on a form, not through code. The exception to this is using the Load statement to load more instances of a control into an existing array. Let's say that you want to press a command button, and have an image control show up on the screen with an image in it. (I think that's what you're trying to do.) You start with one copy of your control on the form. You make it invisible, and set its index property to 0. This makes it the first member of a control array. When the user pushes the command button, you add an image to the control and make it visible. Next time, you use the Load statement to add another control instance to the array, add an image to it, and show it. You continue this process indefinitely or until you reach some sort of limit that you define.

So, boiled down, the process is:
1. Have a control array, with one control, on your form at startup. Make the control invisible.
2. First load, make the control visible.
3. Subsequent loads, load another control into the array, set its properties as you want them, and make it visible.

HTH

Bob
 
Never thought of using a control array with ActiveX controls. Always used control arrays for checkboxes, cmdbuttons,..

Thanks Bob
 
Never thought of using a control array with ActiveX controls. Always used control arrays for checkboxes, cmdbuttons,..

...which are also ActiveX controls


Greetings,
Rick
 
Yeah, I had the feeling that you were familiar with the technique, but it can't hurt to put it down anyway...

<which are also ActiveX controls
Go to Microsoft campus, and you will find that ALL parking spaces not marked "visitor" are marked "Reserved for ActiveX Team"...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top