[Gambas-user] Get the object of a component by name.
Matias De lellis
mati86_dl at ...1877...
Fri Feb 26 22:18:08 CET 2016
El Viernes, 26 de febrero, 2016 18:17:14, Matias De lellis <mati86_dl at ...3322...77...> escribió:
Hi Fabien,
As an idea is good .. I found it very interesting..
I also thought do something similar at the form level, but this implementation requires me to place all components that depend on a Firmata on the same container, forcing distribute all controls on a linear, horizontal or vertical.
This ends up being an important limitation when build a user interface.. Mainly at the time of using several firmata drivers, and I want to combine the controls in a single graphic interface. :S
Unlike is the case of DataView (I think this is a component that was appointed)
where all information should be displayed linear homogenously.. This is not the case.. Here each control is different and can dritribuirse through the entire form
Thanks for all,
Regards,
Matias.
El Miércoles, 24 de febrero, 2016 18:10:30, Fabien Bodard <gambas.fr at ...1162.....626...> escribió:
This is a working example
2016-02-24 21:49 GMT+01:00 Fabien Bodard <gambas.fr at ...626...>:
> You can use another way :
>
> Imagine a firmata that will be a container.
>
> all the children of this container will be connected to this connection.
>
> so you can work visually and children just needto search the
> connection in theire parent
>
>
>
> 2016-02-24 20:22 GMT+01:00 Tobias Boege <taboege at ...626...>:
>> On Wed, 24 Feb 2016, Matias De lellis wrote:
>>> >It is a different>matter, though, if Firmata is a graphical control. Graphical controls always
>>> >have a name property and you can use a Form's Controls property to search a
>>> >control by name like this:
>>> >
>>> > hMyFirmata = FMain.Controls["Firmata1"]
>>> >
>>> >Note again: this only works if you know the form (FMain in this case) where
>>> >you want to search your object and the object is a control.
>>>
>>>
>>> I thought it, but as inherited from SerialPort (Not UserControl) does not work..
>>>
>>> I implemented this in the previous attached example, and prints all controls except virtuals.
>>> > Dim hControl As Control
>>> > Dim hForm As Form Then
>>> > If Me.Parent Is Form ' Always can iterate to find the Form..
>>> > hForm = Me.Parent
>>> > For Each hControl In hForm.Controls
>>> > Debug hControl.name
>>> > Next
>>> > Endif
>>>
>>> May need to do inherit from UserControl but I have to add even more code to relate the UserControl parent with the child SerialPort properties and events..
>>>
>>
>> OK, then another, more self-contained way. You have a class Firmata which is
>> instantiable and you want to keep track of the instances, right? Then modify
>> Firmata.class like so:
>>
>> Static Private $cObjects As New Collection
>>
>> Static Public Sub _get(Name As String) As Firmata
>> ' Search through registered objects
>> Return $cObjects[Name]
>> End
>>
>> Public Sub _new(Name As String)
>> ' Register every newly created Firmata object
>> $cObjects[Name] = Me
>> End
>>
>> There is a static Collection which records every newly created object. You
>> must now specify a name for each Firmata object on creation. Given a string
>> variable sName which contains a the name of an existing Firmata object you
>> can obtain the object simply as
>>
>> hMyFirmata = Firmata[sName]
>>
>> The above code will give you circular reference errors and it does not
>> include a way to remove an instance from the Collection so that its refcount
>> drops to zero and the Firmata object can be deleted. I have not enough time
>> ATM to make a better example, but if you get the idea, I'm sure you can fix
>> the remaining issues.
>>
>> Regards,
>> Tobi
>>
>> --
>> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>>
>> ------------------------------------------------------------------------------
>> Site24x7 APM Insight: Get Deep Visibility into Application Performance
>> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
>> Monitor end-to-end web transactions and take corrective actions now
>> Troubleshoot faster and improve end-user experience. Signup Now!
>> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
>
> --
> Fabien Bodard
--
Fabien Bodard
More information about the User
mailing list