[Gambas-user] Which container to use for Draw Image?
tobias
tobiasboe1 at ...20...
Wed Jan 18 16:18:38 CET 2012
Алексей Беспалов schrieb:
> Thank you, tobias!
> But I do not quite understand what you mean.
> Could give an example of code?
>
> 18 января 2012 г. 21:58 пользователь tobias <tobiasboe1 at ...20...> написал:
>
>> Алексей Беспалов schrieb:
>>> Hi!
>>> Please help me.
>>>
>>>
>>> Which container to use for Draw Image?
>>> So you can determine which of Image Clicked.
>>>
>>> I used to DrawArea at HPanel. But I do not know how to identify the
>> object in
>>> the event DrawArea Click ().
>>>
>>> This is part my code:
>>>
>>> --------------------------------------------------
>>> Public Sub DrawImages(mhImage As Image[], Parent As Container, SizeArea
>> As
>>> Integer)
>>> Dim hImage As Image
>>> Dim hArea As DrawingArea
>>>
>>> MVars.mAreas.Clear()
>>> Parent.Children.Clear()
>>>
>>> For Each hImage In mhImage
>>> hArea = New DrawingArea(Parent)
>>> Object.Attach(hArea, FMain, "hArea")
>>> MVars.mAreas.Add(hArea)
>>>
>>> hArea.Cached = True
>>> hArea.Border = 2
>>>
>>> DrawImage(hImage, hArea, SizeArea) 'Draw Image on hArea
>>> Next
>>> End
>>> ----------------------------------------------------
>>>
>>> In FMain code:
>>>
>>> ----------------------------------------------------
>>> Public Sub hArea_DblClick()
>>> Message.Info("!!!")
>>> End
>>> ----------------------------------------------------
>>> It is work. But can i determine which of Image i Clicked??
>>>
>> since you create multiple DrawingAreas with the same event name, so all
>> objects individually will raise the hArea_DblClick event.
>> but there is one trick: the object that raised a particular event can be
>> referred to from within the event handler by using the Last object.
>> consequently Last will be a reference to the particular DrawingArea
>> dblclicked.
>>
>>
i think source code was originally invented to break the language barrier ;)
Public Sub hArea_DblClick()
Print Last.Cached
End
this will print out the value of the particular DrawingArea.Cached
property. (sry, nothing useful came into my mind with the DrawingArea
class...). see gambasdoc.org/help/lang/last?v3 for details.
More information about the User
mailing list