Valhalla Legends Forums Archive | Visual Basic Programming | Properties of a Control

AuthorMessageTime
Imperceptus
Is there any way to use a For loop to retrieve all the properties of a control?  Maybe something to the extent of ...
[code]
For each property in control
  debug.print property.name
next property
[/code]

Ive tried a few different ways and I am not gaining any ground.

-thanks
May 26, 2006, 9:14 PM
Topaz
Why would you need to do that? The Visual Basic IDE already provides a list of the properties.
May 26, 2006, 10:27 PM
Imperceptus
was just an idea, was curious as to how it would be done if possible... real bored.
May 26, 2006, 10:49 PM
Grok
[quote author=Imperceptus link=topic=15062.msg153204#msg153204 date=1148678073]
Is there any way to use a For loop to retrieve all the properties of a control?  Maybe something to the extent of ...
[code]
For each property in control
  debug.print property.name
next property
[/code]

Ive tried a few different ways and I am not gaining any ground.

-thanks
[/quote]

Yes, but you will need some help from COM programming.  What the VB IDE is doing is using a callback function that queries the interface provided by the control.  The functions/properties list is the interface.  Go to MSDN and look for COM, QueryInterface and start reading.  Chances are you're not that interested.
May 30, 2006, 6:05 AM
Myndfyr
[quote author=Grok link=topic=15062.msg153427#msg153427 date=1148969134]
Yes, but you will need some help from COM programming.  What the VB IDE is doing is using a callback function that queries the interface provided by the control.  The functions/properties list is the interface.  Go to MSDN and look for COM, QueryInterface and start reading.  Chances are you're not that interested.
[/quote]
Hey thanks Grok.  I didn't realize that all VB's controls were COM controls.

If you're just interested in doing this with arbitrary code, Visual Basic .NET supports this through the Type class.  Very handy.  :)
May 30, 2006, 5:48 PM
Clan CDH
i'd hate to bump this topic but i just wanted people to know that the reason all the controls are COM because VB6 relies on the DCOM service to start
July 25, 2006, 1:49 AM
Myndfyr
[quote author=Clan CDH link=topic=15062.msg156062#msg156062 date=1153792197]
i'd hate to bump this topic but i just wanted people to know that the reason all the controls are COM because VB6 relies on the DCOM service to start
[/quote]

I doubt that that's the reason.  It may be a result, but I'm also not sold on that.
July 25, 2006, 4:19 PM
TheMinistered
There is a activex dll packaged with visual basic that makes reading the interfaces much easier.  You WILL HAVE TO READ THE INTERFACE if you want to get the property names.

Goto Project->References and Select Typelib Information.  You might want to read up on this a bit first.  I use this to determine wether an activex dll plugin supports the proper interfaces before I try to load it.  Most people who enumerate a dir just try to load each dll and catch the error, but I check for the interfaces first.
July 27, 2006, 5:57 PM

Search