Subject Re: [IBO] Focus of TIB_Datasource
Author Helen Borrie
At 10:57 PM 7/08/2004 +0200, you wrote:
>Hi Helen,
> > Won't the OnGainFocus and OnLoseFocus events of the datasource work for
> you?
>It is not very convenient to use these events because I am using many
>datasources on my form. So it would have been nice to have a general
>OnDataSourceFocusChanged event in the session object.
>As a workaround, I have done the following: in the constructor of the
>base class for my forms, I iterate through all my datasources (which
>are used on the form) and assign one an the same procedure to the OnGainFocus
>event. In this procedure, I wrote the code which does the stuff I want
>to do for all my datasources when they gain the focus.
>Sometimes, I have to use the OnGainFocus event in forms derived from
>my base class. Then I override the GainFocus procedure of the base
>class, call 'inherited' an then do stuff for specific datasources:
>if DataSource = dsFoo then
>if DataSource = dsBar then
>This works quite fine for me.

Oh, ok. I'd mistakenly assumed that you were trying to track datasources
that were announcing/allowing focus. For that situation, e.g. if I wanted
to display something in the status bar to indicate something to the user
about which ds was currently subject to the update bar, I'd maintain
form-level properties, e.g. DSLastFocused and FocusedDS, that get updated
on the OnGainFocus and OnLoseFocus events.