home *** CD-ROM | disk | FTP | other *** search
-
- {*****************************************************************************}
- { }
- { Animals Demo }
- { }
- { illustrating the use of the }
- { }
- { QDB v2.10 Visual Components for Delphi 1, 2, & 3 }
- { }
- { Copyright (c) 1995, 1996, 1997, 1998, Robert R. Marsh, S.J. }
- { & the British Province of the Society of Jesus }
- { }
- { }
- { You may use this demonstration application and modify it in }
- { whatever way you choose. You may not, however, sell it for }
- { profit unless the changes you have made are substantial (i.e., }
- { more than 50% new code), in which case I'd appreciate }
- { receiving a copy of your new work. }
- { }
- { If you like Animals and find yourself using it please }
- { consider making a donation to your favorite charity. }
- { }
- { Users of Animals must accept the following disclaimer of warranty: }
- { }
- { Animals is supplied as is. The author disclaims all warranties, }
- { expressed or implied, including, without limitation, the }
- { warranties of merchantability and of fitness for any purpose. }
- { The author assumes no liability for damages, direct or }
- { consequential, which may result from the use of Animals. }
- { }
- {*****************************************************************************}
-
- unit ani_main;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Graphics, Forms, Classes, StdCtrls, Buttons,
- ExtCtrls, Controls, QDB;
-
- type
- Tani_form = class(TForm)
- Panel1: TPanel;
- Label1: TLabel;
- BitBtn1: TBitBtn;
- {these are the replacements for their DB counterparts}
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Edit4: TEdit;
- Image1: TImage;
- QDB1: TQDB;
- QDBNavigator1: TQDBNavigator;
- procedure FormCreate(Sender: TObject);
- procedure QDB1Navigate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- private
- end;
-
- var
- ani_form: Tani_form;
-
- implementation
-
- {$R *.DFM}
-
- { The data is of the following format -- }
- { char arrays are slightly easier to deal with than strings }
- type
- TName = array [0..10] of char;
- TSize = array [0..2] of char;
- TWght = array [0..2] of char;
- TArea = array [0..20] of char;
-
- procedure Tani_form.FormCreate(Sender: TObject);
- begin
- {locate and set the QDB file}
- QDB1.FileName:=ChangeFileExt(Application.ExeName,'.qdb');
- {we use a cache size that will hold all the items}
- QDB1.CacheSize:=128*1024;
- {we want to start at the beginning}
- QDB1.FirstItem;
- end;
-
- {every time we move through the database we do this ...}
- procedure Tani_form.QDB1Navigate(Sender: TObject);
- var
- Item: TMemoryStream;
- Name: TName;
- Size: TSize;
- Wght: TWght;
- Area: TArea;
- begin
- {prepare a place for the item}
- Item:=TMemoryStream.Create;
- try
- {get it from the current place in the database}
- QDB1.Get(Item);
- {put the textual data on the form}
- Item.Read(Name,SizeOf(Name));
- Edit1.Text:=Name;
- Item.Read(Size,SizeOf(Size));
- Edit2.Text:=Size;
- Item.Read(Wght,SizeOf(Wght));
- Edit3.Text:=Wght;
- Item.Read(Area,SizeOf(Area));
- Edit4.Text:=Area;
- Image1.Picture.BitMap.LoadFromStream(Item);
- finally
- Item.Free;
- end;
- end;
-
- procedure Tani_form.FormDestroy(Sender: TObject);
- begin
- QDB1.FileName:='';
- end;
-
- end.
-