[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing proxy properties


Le dim. 22 sept. 2024 à 12:55, Bruce Steers <bsteers4@xxxxxxxxx> a écrit :

>
>
> On Sun, 22 Sept 2024 at 11:43, Bruce Steers <bsteers4@xxxxxxxxx> wrote:
>
>>
>>
>> On Sun, 22 Sept 2024 at 09:28, BB <adamnt42@xxxxxxxxx> wrote:
>>
>>>
>>> On 22/9/24 4:20 pm, BB wrote:
>>>
>>> Maybe I'm being overly ambitious here.
>>>
>>> If $control.Proxy.Row < 0 Then Return
>>>
>>> $control is a custom control with a gridview in it, which is the proxy.
>>>
>>> That line above stops the IDE with the error "Unknown symbol 'row' in
>>> class 'Control' "
>>>
>>> but in the IDE I can see (i.e. debug) the $control Proxy property and
>>> see the actual Proxy as per the picture attached.
>>>
>>> Is the $control.Proxy.Row construct wrong?
>>>
>>> tia
>>>
>>> b
>>>
>>>
>>> AH nevermind.
>>>
>>> I can see now what I was trying cant work, because Proxy is a Control,
>>> not the actual object's class. The IDE must do some magic to see it as it
>>> is.
>>>
>>> Damn! I thought I'd found a neat way to get at the proxy's properties.
>>>
>>> I know the Proxy's job is only to duplicate mouse and keyboard events
>>> but I just thought, maybe....
>>>
>>> Oh well, back to work.
>>>
>> It's not magic, it's just a trick ;)
>>
>> Just access it assigning the gridview class or use Object.class to use
>> any property.
>> Ie.
>>
>> Dim hGrid As GridView = $control.Proxy
>> Print hGrid.Row
>>
>> Or..
>>
>> Dim hObject As Object = $control.Proxy
>> Print hObject.Row
>>
>> If the type could vary you could use Object.Type($control.Proxy) to see
>> exactly what it is.
>>
>> Respects
>> BruceS
>>
>
>
> I must say although technically incorrect there are many properties in
> gambas that are Control.class but Object.class would be much more useful.
>
> Window.Controls , Control.Proxy , etc
>
> if it was Window.Controls As Object[]  and Control.Proxy As Object then it
> would make for some much simpler programming.
>
> But then again i guess it don't take much of a command to get over this.
>
> Public Sub ControlObject(Ctrl As Control) As Object
>   Return Ctrl
> End
>
> Print ControlObject($control.Proxy).Row
>
>
Or just
Dim o as Object = Control.Proxy
Print o.Row


-- 
Fabien Bodard

Follow-Ups:
Re: Accessing proxy propertiesBB <adamnt42@xxxxxxxxx>
References:
Accessing proxy propertiesBB <adamnt42@xxxxxxxxx>
Re: Accessing proxy propertiesBB <adamnt42@xxxxxxxxx>
Re: Accessing proxy propertiesBruce Steers <bsteers4@xxxxxxxxx>
Re: Accessing proxy propertiesBruce Steers <bsteers4@xxxxxxxxx>