[Gambas-user] What type of control is it?

Tobias Boege taboege at ...626...
Mon Sep 30 09:26:40 CEST 2013


On Mon, 30 Sep 2013, Bruce wrote:
> Aaaaarrrgghhh!  I've done this a zillion times before but today I can't
> find an example.
> 
> 
> How do I get the type of the Application.CurrentControl control?
> 
> It's not TypeOf() as that returns gb.Object
> I need to know if it has a text or value so I can copy it to the
> clipboard,
> 

To get the type (class name) of an object (you were so close :-)):

	  Object.Type(Application.CurrentControl)

but you could also directly check for a Text or Value property:

	  Dim hClass As Class = Object.Class(Application.CurrentControl)

	  If hClass.Exist("Text") And If hClass["Text"].Kind = Class.Property Then
	    HasText()
	  Else If hClass.Exist("Value") And If hClass["Value"].Kind = Class.Property Then
	    HasValue()
	  Endif

or probably a bit faster but a little ugly:

	  Dim vValue As Variant

	  Try vValue = Application.CurrentControl.Value
	  If Not Error Goto _Found
          Try vValue = Application.CurrentControl.Text
	  If Not Error Goto _Found
	  NothingToCopy()
	  Return
	_Found:
	  CopyToClipboard()

Regards,
Tobi




More information about the User mailing list