[Gambas-user] Object names

Charlie Reinl Karl.Reinl at ...9...
Fri Oct 27 00:15:42 CEST 2006


Am Donnerstag, den 26.10.2006, 12:09 -0700 schrieb Christopher Brian
Jack:
> Say I have a Form with a control, say a textbox that happens to be called
> TextBox1
> 
> Now say I have a function of the form:
> 
> PUBLIC SUB SomeSub(client as Control)
> 
> ...
> 
> END
> 
> Is there any way to find out the client's name (eg: TextBox1)?
> 
Salut,

dit you think about something like that ?

this is MEditorColors.module

' Gambas module file
CONST myGotFocusColor AS Integer  = &HAAFF7F&
CONST myLostFocusColor AS Integer = &HF9F9BD&
PUBLIC SUB SetEditColor(oObj AS Object, objLast AS Control)
DIM myControl AS String
DIM hClass AS Control
DIM hCont AS Container
    myControl = Object.Class(objLast)
    FOR EACH hClass IN oObj.Children
      ' is it like my LAST ?
      IF Object.Class(hClass) = myControl THEN
        ' only for debugging
        'PRINT  Object.Class(hClass) & "     LAST.TAG = " & objLast.Tag
& "          hClass.Tag = "  & hClass.Tag
        IF objLast.Tag = hClass.Tag THEN
            hClass.Background = myGotFocusColor
        ELSE
            hClass.Background = myLostFocusColor
        ENDIF
      ELSE
        ' TRY if it is a Container
        TRY hCont = hClass
        IF NOT ERROR THEN
            ' I call my self to find out if there are Cildren like my
LAST
            SetEditColor(hClass, objLast)
        ENDIF
      ENDIF
    NEXT
END


this is called by :

Public SUB Col_GotFocus()
	MEditorColors.SetEditColor(ME, LAST)
END

May be that gives you an Idea. (It came from gambas1)

Amicalment
Charlie





More information about the User mailing list