Marco Cantù 1998, Mastering Delphi 4

Project: TWOVIEWS.DPR


Project Structure


TWOVIEWS.DPR

program TwoViews;

uses
  Forms,
  GridView in 'GridView.pas' {Form1},
  DataM in 'DataM.pas' {DataModule2},
  FormView in 'FormView.pas' {Form3};

{$R *.RES}

begin
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TDataModule2, DataModule2);
  Application.CreateForm(TForm3, Form3);
  Application.Run;
end.

GRIDVIEW.PAS

unit GridView;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, DBGrids, Buttons, DBCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    DBNavigator1: TDBNavigator;
    SpeedButtonView: TSpeedButton;
    DBGrid1: TDBGrid;
    procedure SpeedButtonViewClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses DataM, FormView;

{$R *.DFM}

procedure TForm1.SpeedButtonViewClick(Sender: TObject);
begin
  Form3.Show;
end;

end.

DATAM.PAS

unit DataM;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DBTables, DB;

type
  TDataModule2 = class(TDataModule)
    Table1: TTable;
    DataSource1: TDataSource;
    Table1CustNo: TFloatField;
    Table1Company: TStringField;
    Table1Addr1: TStringField;
    Table1Addr2: TStringField;
    Table1City: TStringField;
    Table1State: TStringField;
    Table1Zip: TStringField;
    Table1Country: TStringField;
    Table1Phone: TStringField;
    Table1FAX: TStringField;
    Table1TaxRate: TFloatField;
    Table1Contact: TStringField;
    Table1LastInvoiceDate: TDateTimeField;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DataModule2: TDataModule2;

implementation

{$R *.DFM}

end.

FORMVIEW.PAS

unit FormView;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, DBCtrls, StdCtrls, Mask;

type
  TForm3 = class(TForm)
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit4: TDBEdit;
    DBEdit5: TDBEdit;
    DBEdit6: TDBEdit;
    DBEdit7: TDBEdit;
    DBEdit8: TDBEdit;
    DBEdit9: TDBEdit;
    DBEdit10: TDBEdit;
    DBEdit11: TDBEdit;
    DBEdit12: TDBEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    DBNavigator1: TDBNavigator;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

uses DataM;

{$R *.DFM}

end.

GRIDVIEW.DFM

object Form1: TForm1
  Left = 52
  Top = 108
  Width = 410
  Height = 300
  Caption = 'Grid View'
  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 Panel1: TPanel
    Left = 0
    Top = 0
    Width = 402
    Height = 41
    Align = alTop
    ParentShowHint = False
    ShowHint = True
    TabOrder = 0
    object SpeedButtonView: TSpeedButton
      Left = 16
      Top = 8
      Width = 25
      Height = 25
      Hint = 'Open Form View'
      Flat = True
      Glyph.Data = {
        76010000424D7601000000000000760000002800000020000000100000000100
        04000000000000010000120B0000120B00001000000000000000000000000000
        800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
        FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
        33333FFFFFFFFFFFFFFF000000000000000077777777777777770FFFFFFFFFFF
        FFF07F3FF3FF3FFF3FF70F00F00F000F00F07F773773777377370FFFFFFFFFFF
        FFF07F3FF3FF33FFFFF70F00F00FF00000F07F773773377777F70FEEEEEFF0F9
        FCF07F33333337F7F7F70FFFFFFFF0F9FCF07F3FFFF337F737F70F0000FFF0FF
        FCF07F7777F337F337370F0000FFF0FFFFF07F777733373333370FFFFFFFFFFF
        FFF07FFFFFFFFFFFFFF70CCCCCCCCCCCCCC07777777777777777088CCCCCCCCC
        C880733777777777733700000000000000007777777777777777333333333333
        3333333333333333333333333333333333333333333333333333}
      NumGlyphs = 2
      OnClick = SpeedButtonViewClick
    end
    object DBNavigator1: TDBNavigator
      Left = 41
      Top = 8
      Width = 240
      Height = 25
      DataSource = DataModule2.DataSource1
      Flat = True
      TabOrder = 0
    end
  end
  object DBGrid1: TDBGrid
    Left = 0
    Top = 41
    Width = 402
    Height = 232
    Align = alClient
    DataSource = DataModule2.DataSource1
    TabOrder = 1
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
end

DATAM.DFM

object DataModule2: TDataModule2
  Left = 300
  Top = 370
  Height = 159
  Width = 196
  object Table1: TTable
    Active = True
    DatabaseName = 'DBDEMOS'
    TableName = 'CUSTOMER.DB'
    Left = 24
    Top = 16
    object Table1CustNo: TFloatField
      DisplayWidth = 7
      FieldName = 'CustNo'
    end
    object Table1Company: TStringField
      DisplayWidth = 25
      FieldName = 'Company'
      Size = 30
    end
    object Table1Addr1: TStringField
      DisplayWidth = 21
      FieldName = 'Addr1'
      Size = 30
    end
    object Table1Addr2: TStringField
      DisplayWidth = 28
      FieldName = 'Addr2'
      Size = 30
    end
    object Table1City: TStringField
      DisplayWidth = 15
      FieldName = 'City'
      Size = 15
    end
    object Table1State: TStringField
      DisplayWidth = 20
      FieldName = 'State'
    end
    object Table1Zip: TStringField
      DisplayWidth = 10
      FieldName = 'Zip'
      Size = 10
    end
    object Table1Country: TStringField
      DisplayWidth = 20
      FieldName = 'Country'
    end
    object Table1Phone: TStringField
      DisplayWidth = 15
      FieldName = 'Phone'
      Size = 15
    end
    object Table1FAX: TStringField
      DisplayWidth = 15
      FieldName = 'FAX'
      Size = 15
    end
    object Table1TaxRate: TFloatField
      DisplayWidth = 10
      FieldName = 'TaxRate'
    end
    object Table1Contact: TStringField
      DisplayWidth = 20
      FieldName = 'Contact'
    end
    object Table1LastInvoiceDate: TDateTimeField
      DisplayWidth = 13
      FieldName = 'LastInvoiceDate'
    end
  end
  object DataSource1: TDataSource
    DataSet = Table1
    Left = 88
    Top = 16
  end
end

FORMVIEW.DFM

object Form3: TForm3
  Left = 464
  Top = 108
  Width = 289
  Height = 360
  Caption = 'Form View'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Visible = True
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 16
    Top = 44
    Width = 64
    Height = 13
    Caption = 'Customer No.'
  end
  object Label2: TLabel
    Left = 16
    Top = 68
    Width = 44
    Height = 13
    Caption = 'Company'
  end
  object Label3: TLabel
    Left = 16
    Top = 92
    Width = 53
    Height = 13
    Caption = 'Address (1)'
  end
  object Label4: TLabel
    Left = 16
    Top = 116
    Width = 53
    Height = 13
    Caption = 'Address (2)'
  end
  object Label5: TLabel
    Left = 16
    Top = 140
    Width = 17
    Height = 13
    Caption = 'City'
  end
  object Label6: TLabel
    Left = 16
    Top = 164
    Width = 25
    Height = 13
    Caption = 'State'
  end
  object Label7: TLabel
    Left = 16
    Top = 188
    Width = 17
    Height = 13
    Caption = 'ZIP'
  end
  object Label8: TLabel
    Left = 16
    Top = 212
    Width = 36
    Height = 13
    Caption = 'Country'
  end
  object Label9: TLabel
    Left = 16
    Top = 236
    Width = 31
    Height = 13
    Caption = 'Phone'
  end
  object Label10: TLabel
    Left = 16
    Top = 260
    Width = 20
    Height = 13
    Caption = 'FAX'
  end
  object Label11: TLabel
    Left = 16
    Top = 284
    Width = 44
    Height = 13
    Caption = 'Tax Rate'
  end
  object Label12: TLabel
    Left = 16
    Top = 308
    Width = 37
    Height = 13
    Caption = 'Contact'
  end
  object DBEdit1: TDBEdit
    Left = 88
    Top = 40
    Width = 89
    Height = 21
    DataField = 'CustNo'
    DataSource = DataModule2.DataSource1
    TabOrder = 0
  end
  object DBEdit2: TDBEdit
    Left = 88
    Top = 64
    Width = 177
    Height = 21
    DataField = 'Company'
    DataSource = DataModule2.DataSource1
    TabOrder = 1
  end
  object DBEdit3: TDBEdit
    Left = 88
    Top = 88
    Width = 177
    Height = 21
    DataField = 'Addr1'
    DataSource = DataModule2.DataSource1
    TabOrder = 2
  end
  object DBEdit4: TDBEdit
    Left = 88
    Top = 112
    Width = 177
    Height = 21
    DataField = 'Addr2'
    DataSource = DataModule2.DataSource1
    TabOrder = 3
  end
  object DBEdit5: TDBEdit
    Left = 88
    Top = 136
    Width = 97
    Height = 21
    DataField = 'City'
    DataSource = DataModule2.DataSource1
    TabOrder = 4
  end
  object DBEdit6: TDBEdit
    Left = 88
    Top = 160
    Width = 97
    Height = 21
    DataField = 'State'
    DataSource = DataModule2.DataSource1
    TabOrder = 5
  end
  object DBEdit7: TDBEdit
    Left = 88
    Top = 184
    Width = 97
    Height = 21
    DataField = 'Zip'
    DataSource = DataModule2.DataSource1
    TabOrder = 6
  end
  object DBEdit8: TDBEdit
    Left = 88
    Top = 208
    Width = 97
    Height = 21
    DataField = 'Country'
    DataSource = DataModule2.DataSource1
    TabOrder = 7
  end
  object DBEdit9: TDBEdit
    Left = 88
    Top = 232
    Width = 97
    Height = 21
    DataField = 'Phone'
    DataSource = DataModule2.DataSource1
    TabOrder = 8
  end
  object DBEdit10: TDBEdit
    Left = 88
    Top = 256
    Width = 97
    Height = 21
    DataField = 'FAX'
    DataSource = DataModule2.DataSource1
    TabOrder = 9
  end
  object DBEdit11: TDBEdit
    Left = 88
    Top = 280
    Width = 97
    Height = 21
    DataField = 'TaxRate'
    DataSource = DataModule2.DataSource1
    TabOrder = 10
  end
  object DBEdit12: TDBEdit
    Left = 88
    Top = 304
    Width = 177
    Height = 21
    DataField = 'Contact'
    DataSource = DataModule2.DataSource1
    TabOrder = 11
  end
  object DBNavigator1: TDBNavigator
    Left = 16
    Top = 8
    Width = 250
    Height = 25
    DataSource = DataModule2.DataSource1
    TabOrder = 12
  end
end


Copyright Marco Cantù 1998