Subject Re: Creating new data-components with IBObjects
Author sdbeames
> are there any guidelines or tutorials/howtos on
> how to create new components that are linked to
> a Datasource and automatically load/save their
> content?
> I tried to look at the ibo sourcecode to find
> out how you do it for e.g. the TEdit control,
> but imho the sourcecode is unreadable with all
> those {$I} directives... I couldn't figure it out
> that way.
>
> Thanks,
> Daniel Albuschat

Hi Daniel,
I've recently written my first component (using BCB5) and I ended
up just providing a DataSource property and using a TIB_Query*
thus...

private:
TIB_DataSource *FDataSource;
...
public:
TIB_Query *pQry;

__published:
__property TIB_DataSource *DataSource = {read=FDataSource,
write=FDataSource};
...

then in Loaded() I did...
if (!ComponentState.Contains(csDesigning) && FDataSource)
{
pQry = dynamic_cast<TIB_Query*>(FDataSource->Dataset);
if (pQry)
{
pQry->Open();
FStoredAfterRollbackRetaining = pQry->IB_Transaction-
>AfterRollbackRetaining;
pQry->IB_Transaction->AfterRollbackRetaining =
OnAfterRollbackRetaining;
}
}
else pQry = 0;

and from then on, I just access the dataset via pQry.

If there's a better way I'd like to hear it too.

HTH,
Steve

PS. Using V4.3Ab_Test I had to change csLoading to csReading in
IB_Components.pas functions TIB_Statement.SysPrepare and
TIB_Dataset.SysOpen, to allow a custom component to initialise owned
TIB components in its Loaded() method. I've sent the changes to
Jason, but don't know if he's reviewed them yet.