Marco Web Center |
|
Chapter 18 - Project StreamDsDemo |
Project Structure |
StreamDsDemo.dpr |
program StreamDsDemo; uses Forms, StreamDsForm in 'StreamDsForm.pas' {Form1}; {$R *.RES} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. |
StreamDsForm.pas |
unit StreamDsForm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Db, Grids, DBGrids, ExtCtrls, DBCtrls, MdDsStream, MdDsCustom; type TForm1 = class(TForm) DataSource1: TDataSource; DBGrid1: TDBGrid; Panel1: TPanel; Button1: TButton; CheckBox1: TCheckBox; DBNavigator1: TDBNavigator; Button2: TButton; MdDataSetStream1Name: TStringField; MdDataSetStream1Level: TIntegerField; MdDataSetStream1BirthDate: TDateField; MdDataSetStream1Stipend: TCurrencyField; MdDataSetStream1Email: TStringField; MdDataSetStream1Editor: TBooleanField; MdDataSetStream1: TMdDataSetStream; procedure Button1Click(Sender: TObject); procedure CheckBox1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin MdDataSetStream1.CreateTable; MdDataSetStream1.Open; CheckBox1.Checked := MdDataSetStream1.Active; end; procedure TForm1.CheckBox1Click(Sender: TObject); begin MdDataSetStream1.Active := CheckBox1.Checked; end; procedure TForm1.FormCreate(Sender: TObject); begin MdDataSetStream1.TableName := ExtractFilePath (ParamStr (0)) + 'Contrib.dso'; end; procedure TForm1.Button2Click(Sender: TObject); var bm: TBookmarkStr; begin bm := MdDataSetStream1.Bookmark; MdDataSetStream1.First; while not MdDataSetStream1.EOF do MdDataSetStream1.Next; MdDataSetStream1.Bookmark := bm; end; end. |
StreamDsForm.dfm |
object Form1: TForm1 Left = 263 Top = 203 Width = 578 Height = 366 Caption = 'Dataset One Demo' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = True OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object DBGrid1: TDBGrid Left = 0 Top = 41 Width = 570 Height = 298 Align = alClient DataSource = DataSource1 TabOrder = 0 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -11 TitleFont.Name = 'MS Sans Serif' TitleFont.Style = [] end object Panel1: TPanel Left = 0 Top = 0 Width = 570 Height = 41 Align = alTop TabOrder = 1 object Button1: TButton Left = 16 Top = 8 Width = 105 Height = 25 Caption = 'Create New Table' TabOrder = 0 OnClick = Button1Click end object CheckBox1: TCheckBox Left = 135 Top = 11 Width = 74 Height = 17 Caption = 'Active' TabOrder = 1 OnClick = CheckBox1Click end object DBNavigator1: TDBNavigator Left = 200 Top = 8 Width = 240 Height = 25 DataSource = DataSource1 TabOrder = 2 end object Button2: TButton Left = 448 Top = 8 Width = 105 Height = 25 Caption = 'Bookmark test' TabOrder = 3 OnClick = Button2Click end end object DataSource1: TDataSource DataSet = MdDataSetStream1 Left = 64 Top = 112 end object MdDataSetStream1: TMdDataSetStream TableName = 'c:\md6code\18\StreamDsDemo\contrib.dso' Left = 64 Top = 168 object MdDataSetStream1Name: TStringField FieldName = 'Name' Size = 30 end object MdDataSetStream1Level: TIntegerField FieldName = 'Level' end object MdDataSetStream1BirthDate: TDateField FieldName = 'BirthDate' end object MdDataSetStream1Stipend: TCurrencyField FieldName = 'Stipend' end object MdDataSetStream1Email: TStringField FieldName = 'Email' Size = 50 end object MdDataSetStream1Editor: TBooleanField FieldName = 'Editor' end end end |