Subject Re: [IBO] TIB_updateBar
Author Helen Borrie
At 01:34 PM 29/04/2003 +0200, you wrote:
>Hi Helen,
> > "For example, in an MDI application the user could go from one child
> > to another. Each child window could have its own DataSource context. Thus,
> > if each child window's DataSource component's AnnounceFocus property is
> > to true the SearchBar will receive the focus and align with it.
>That is the theory how this component should work if using the AnnounceFocus
>functionality. Ok, I think I've got it.
> > I'm assuming you have your data objects on a datamodule and, currently,
> > have one ib_datasource there, associated with each dataset
> > component. That's fine for a lot of application designs, but you don't
> > *have* to lock them together like this. You can use as many datasources
> > per dataset as you need and they can be owned by any form or
> > datamodule. Just create *separate* ib_datasources with each child form,
> > making the child form the owner of the datasource - remembering to take
> > good care of creation order, of course. :-))
>Well, more or less, that is my design, with some slight modifications.
>Actually I use a TIB_updateBar on every MDI-child form with TIB_Query and
>TIB_Datasources on every MDI-form. The TIB_connection component is on a
>central data-module together with some general purpose components like
>TIB_Script, TIB_SyncCursorDML, TIB_SessionProps etc. When creating a new
>instance of a MDI-Child I submit the database handle to MDI-form and assign
>the db-handle to datasets via code. Up to know it seems to work this way.
>Cause I don't like the design of the TIB_UpdateBar component so much, I use
>TBitBtn components with my own bitmaps. To syncronize the button.enabled
>property with the TIB_UpdateBar buttons, I use this code :
>procedure TfrmMDIChild.IB_UpdateBarButtonsStateChanged(Sender: TObject);
> BitBtnInsert.enabled :=IB_UpdateBar.Buttons[ubInsert].enabled;
> BitBtnDelete.enabled :=IB_UpdateBar.Buttons[ubDelete].enabled;
> BitBtnPost.enabled :=IB_UpdateBar.Buttons[ubPost].enabled;
> BitBtnCancel.enabled :=IB_UpdateBar.Buttons[ubCancel].enabled;
>All works fine, until I open a second instance! I try to translate the
>german error message :
>"Error reading from IB_UpdateBar.Receivefocus. Exception in address xxxxxx"
>Maybe two important thing to notice :
>If I open the first MDI-child and don't assign one datasource to the
>IB_UpdateBar (with activating any of the data sensitive components) I can
>open a second instance without error message.
>If I disable the code above no error message too.

I wouldn't start to guess what's causing the ReceiveFocus error but I
suspect that your buttonclicks might be interfering. I always look for the
simple solution if I can...surrogating the Bar buttons with bitbuttons
doesn't strike me as simple..

Did you know that you can replace the glyphs on TIB_UpdateBar with your own
glyphs? That's the solution I would go for, so that you can make full use
of the UpdateBar's ReceiveFocus and the AnnounceFocus of the datasets.

Another handy component you might not have tried is
TIB_ConnectionSource. If you drop one on each child form at design-time
and have the form create it first, I think it will simplify and tidy up
the creation and destruction of these data-aware modules. You might like
to look at TIB_TransactionSource for a similar "tidy" solution...