tags:

views:

879

answers:

2

Hi, I have inherited a load of VB6 code which has tons of individual OCX files, each of which contain a single control. I have two questions:

Firstly, Is it possible to refactor them so that I can have a single OCX file with all the OCX's in it?

Secondly, if it is possible, how do I do this?

TIA

+6  A: 

Yes this is possible.

You can do this by selecting Project->Add User Control from within an existing ActiveX User Control project. From here you can choose to add a new control to the project or add an existing user control.

Also, it can certainly make sense to group related controls together into a single project, as long as you group controls according to some kind of logic. For example, the Forms 2.0 library groups "commonly-used" controls together (Textbox, Checkbox, Combobox, Label, etc.) into a single library.

Mike Spross
+1  A: 

While you can have multiple controls in a single OCX, be sure to use some foresight. You don't want to clutter your toolbox with controls you very infrequently use in your VB projects to simply use those you do frequently use.

Also, bundling multiple controls in a single .ocx can add overhead in terms of app size and load time if you aren't using all of those controls. Perhaps these were in individual files for these and other reasons worthy of consideration before you proceed to re-factor this. You may wish to consult the former coder (if feasible) to determine their reasoning for doing this.

coderGeek