Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Imperceptus on May 26, 2006, 04:14 PM

Title: Properties of a Control
Post by: Imperceptus on May 26, 2006, 04:14 PM
Is there any way to use a For loop to retrieve all the properties of a control?  Maybe something to the extent of ...

For each property in control
  debug.print property.name
next property


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

-thanks
Title: Re: Properties of a Control
Post by: topaz on May 26, 2006, 05:27 PM
Why would you need to do that? The Visual Basic IDE already provides a list of the properties.
Title: Re: Properties of a Control
Post by: Imperceptus on May 26, 2006, 05:49 PM
was just an idea, was curious as to how it would be done if possible... real bored.
Title: Re: Properties of a Control
Post by: Grok on May 30, 2006, 01:05 AM
Quote from: Imperceptus on May 26, 2006, 04:14 PM
Is there any way to use a For loop to retrieve all the properties of a control?  Maybe something to the extent of ...

For each property in control
  debug.print property.name
next property


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

-thanks

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.
Title: Re: Properties of a Control
Post by: MyndFyre on May 30, 2006, 12:48 PM
Quote from: Grok on May 30, 2006, 01:05 AM
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.
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 (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclasstopic.asp) class.  Very handy.  :)
Title: Re: Properties of a Control
Post by: Clan CDH on July 24, 2006, 08:49 PM
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
Title: Re: Properties of a Control
Post by: MyndFyre on July 25, 2006, 11:19 AM
Quote from: Clan CDH on July 24, 2006, 08:49 PM
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

I doubt that that's the reason.  It may be a result, but I'm also not sold on that.
Title: Re: Properties of a Control
Post by: TheMinistered on July 27, 2006, 12:57 PM
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.