Subject Re: [IBO] Saving and loading queries FieldIndex and FieldDisplayWidth values
Author Elmar Knoerzer
Hallo Andreas,
i found the following solution.

Now i will test it.

Regards Elmar

unit IB_GridQuery;

interface

uses
SysUtils, Classes, IB_Components, Dialogs;

type
TIB_GridQuery = class(TIB_Query)
private
{ Private-Deklarationen }
FGridSave: Boolean;
protected
{ Protected-Deklarationen }
procedure SetGridSave(AValue: Boolean);
public
{ Public-Deklarationen }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure doBeforeOpen; override;
procedure doBeforeClose; override;
published
{ Published-Deklarationen }
property GridSave: Boolean read FGridSave write SetGridSave;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('iboAccess', [TIB_GridQuery]);
end;

constructor TIB_GridQuery.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;

destructor TIB_GridQuery.Destroy;
begin
inherited Destroy;
end;

procedure TIB_GridQuery.SetGridSave(AValue: Boolean);
begin
FGridSave := AValue;
end;

procedure TIB_GridQuery.doBeforeOpen;
begin
inherited;
if FGridSave then
begin
try
self.BeginLayout;
// Load Settings...
finally
self.EndLayout;
end;
end;
end;

procedure TIB_GridQuery.doBeforeClose;
begin
inherited;
if FGridSave then
begin
// Save Settings
end;
end;

end.



--- In IBObjects@yahoogroups.com, Andreas Pohl <apohl@...> wrote:
>
> Hallo Elmar Knoerzer,
>
> > Hi,
> > it's easy to save and load queries FieldIndex and FieldDisplayWidth
> > values with commatext.
> >
> > Now i like to make a descendant of TIB_Query to do this automatically.
>
> take a look to DoBeforeOpen() and DoBeforeClose() of TIB_Query;
>
> I subclassed TIB_Query and TIB_Connection and introduced events
> TIBP_Connection.OnBeforeIBPQueryOpen and
> TIBP_Connection.OnBeforeIBPQueryClose to load and save settings.
>
> HTH.
>
> --
> Andreas
>