Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 18 - Project DbTrack

Project Structure

DbTrack.dpr
program DbTrack;

uses
  Forms,
  DbTrackF in 'DbTrackF.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
DbTrackF.pas
unit DbTrackF;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,
  Forms, Dialogs, DB, ExtCtrls, DBCtrls, StdCtrls, ComCtrls,
  DBTables, Mask, MdTrack;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    DBText1: TDBText;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit5: TDBEdit;
    DBNavigator1: TDBNavigator;
    Table1: TTable;
    Table1OrderNo: TFloatField;
    Table1ItemNo: TFloatField;
    Table1PartNo: TFloatField;
    Table1Qty: TIntegerField;
    Table1Discount: TFloatField;
    DataSource2: TDataSource;
    MdDbTrack1: TMdDbTrack;
    MdDbTrack2: TMdDbTrack;
    CheckTable: TCheckBox;
    BtnConnect: TButton;
    BtnDisconnect: TButton;
    Bevel1: TBevel;
    procedure CheckTableClick(Sender: TObject);
    procedure BtnConnectClick(Sender: TObject);
    procedure BtnDisconnectClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.CheckTableClick(Sender: TObject);
begin
  Table1.Active := CheckTable.Checked;
end;

procedure TForm1.BtnConnectClick(Sender: TObject);
begin
  MdDbTrack2.DataField := 'Discount';
end;

procedure TForm1.BtnDisconnectClick(Sender: TObject);
begin
  MdDbTrack2.DataField := '';
end;

end.
DbTrackF.dfm
object Form1: TForm1
  Left = 284
  Top = 172
  Width = 455
  Height = 300
  Caption = 'Data-aware TrackBar Demo'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 88
    Top = 24
    Width = 40
    Height = 13
    Caption = 'OrderNo'
    FocusControl = DBEdit1
  end
  object Label2: TLabel
    Left = 8
    Top = 24
    Width = 34
    Height = 13
    Caption = 'ItemNo'
    FocusControl = DBEdit2
  end
  object Label3: TLabel
    Left = 184
    Top = 24
    Width = 33
    Height = 13
    Caption = 'PartNo'
    FocusControl = DBEdit3
  end
  object Label4: TLabel
    Left = 24
    Top = 80
    Width = 16
    Height = 13
    Caption = 'Qty'
  end
  object Label5: TLabel
    Left = 288
    Top = 24
    Width = 42
    Height = 13
    Caption = 'Discount'
    FocusControl = DBEdit5
  end
  object DBText1: TDBText
    Left = 56
    Top = 80
    Width = 65
    Height = 17
    DataField = 'Qty'
    DataSource = DataSource2
  end
  object Bevel1: TBevel
    Left = 43
    Top = 202
    Width = 177
    Height = 57
  end
  object DBEdit1: TDBEdit
    Left = 88
    Top = 40
    Width = 64
    Height = 21
    DataField = 'OrderNo'
    DataSource = DataSource2
    TabOrder = 0
  end
  object DBEdit2: TDBEdit
    Left = 8
    Top = 40
    Width = 64
    Height = 21
    DataField = 'ItemNo'
    DataSource = DataSource2
    TabOrder = 1
  end
  object DBEdit3: TDBEdit
    Left = 184
    Top = 40
    Width = 64
    Height = 21
    DataField = 'PartNo'
    DataSource = DataSource2
    TabOrder = 2
  end
  object DBEdit5: TDBEdit
    Left = 288
    Top = 40
    Width = 64
    Height = 21
    DataField = 'Discount'
    DataSource = DataSource2
    TabOrder = 3
  end
  object DBNavigator1: TDBNavigator
    Left = 24
    Top = 152
    Width = 220
    Height = 25
    DataSource = DataSource2
    TabOrder = 4
  end
  object MdDbTrack1: TMdDbTrack
    Left = 16
    Top = 96
    Width = 241
    Height = 45
    Enabled = False
    Max = 100
    Orientation = trHorizontal
    PageSize = 10
    Frequency = 10
    Position = 0
    SelEnd = 0
    SelStart = 0
    TabOrder = 5
    TickMarks = tmBottomRight
    TickStyle = tsAuto
    DataField = 'Qty'
    DataSource = DataSource2
  end
  object MdDbTrack2: TMdDbTrack
    Left = 296
    Top = 72
    Width = 49
    Height = 185
    Enabled = False
    Max = 100
    Orientation = trVertical
    Frequency = 10
    Position = 0
    SelEnd = 0
    SelStart = 0
    TabOrder = 6
    TickMarks = tmBottomRight
    TickStyle = tsAuto
    DataSource = DataSource2
  end
  object CheckTable: TCheckBox
    Left = 88
    Top = 224
    Width = 97
    Height = 17
    Caption = 'Table Active'
    TabOrder = 7
    OnClick = CheckTableClick
  end
  object BtnConnect: TButton
    Left = 360
    Top = 104
    Width = 75
    Height = 25
    Caption = 'Connect'
    TabOrder = 8
    OnClick = BtnConnectClick
  end
  object BtnDisconnect: TButton
    Left = 360
    Top = 136
    Width = 75
    Height = 25
    Caption = 'Disconnect'
    TabOrder = 9
    OnClick = BtnDisconnectClick
  end
  object Table1: TTable
    DatabaseName = 'DBDEMOS'
    TableName = 'ITEMS.DB'
    Left = 40
    Top = 32
    object Table1OrderNo: TFloatField
      FieldName = 'OrderNo'
    end
    object Table1ItemNo: TFloatField
      FieldName = 'ItemNo'
    end
    object Table1PartNo: TFloatField
      FieldName = 'PartNo'
    end
    object Table1Qty: TIntegerField
      FieldName = 'Qty'
    end
    object Table1Discount: TFloatField
      FieldName = 'Discount'
    end
  end
  object DataSource2: TDataSource
    DataSet = Table1
    Left = 40
    Top = 88
  end
end