0

I have a VB 6 control file ( example. ctl ) file, my requirement is to change the properties of this file at runtime...basically some kinda bulk operations...(change the properties of all the ctl files )

This ctl file is part of a project..

Is it possible to change the properties for example height = 100 width = 200 background = white font = calibri

via code, for example using batch file or c# or vb ??...Is there a tool available already??

Kartikkumar Rao
  • 171
  • 2
  • 18

2 Answers2

2

The ctl files exist only within your development environment. Once compiled into your application they become part of the compiled output and you will only be able to modify properties of objects that are instantiated according to the rules defined within your control files.

If each of the controls expose height, width and background fonts as properties, then you will be able to manipulate the controls at runtime in the way that you wish. If you have a list of control objects that you wish to manipulate in this way you can create a list of them and iterate through them.

BrianC
  • 316
  • 1
  • 6
1

I'm using a custom VB6 IDE Add-In to get a reference to VBIDE.VBE. Then in immediate window or in a public function all modules in all loaded projects can be manipulated with code.

Register GetVBERef.dll, load Get VBE Reference add-in in VB6 IDE, open Project2.vbp from the zip and type this in immediate window:

For Each oCmp In VBERef.ActiveVBProject.VBComponents: ? oCmp.Name: Next

(You'll get Module2 only because there is nothing more in Project2)

You can copy/paste the code from Module2 in your project and add a reference to Microsoft Visual Basic 6.0 Extensibility. With a bit of trial & error you can write a public function (in the same module for instance) that resizes all user controls or sets colors, fonts, etc. of all forms in your project group.

wqw
  • 11,771
  • 1
  • 33
  • 41
  • Thanks for the sample Addin wqw, I am looking for something that should not be present in the current project/module. A third party (preferably c# )application that will open all the vb projects, get the control files (.ctl ) and then work on their properties and then close the vb project... I am guessing I need to rewrite the GetVBRef.dll in C#...and then include this in another C# application that can work on the VB projects... Is it possible to do this by just including `Microsoft Visual Basic 6.0 Extensibility` ??? – Kartikkumar Rao Dec 27 '12 at 14:17
  • You don't need to change your existing projects. Just make a project group including your projects and a special "design-time only" project (`Project2` in sample) that implements `VBERef` and a public function that will process the user controls in your projects. Call this function from immediate window in design-time. – wqw Dec 27 '12 at 20:45