Marco Cantù 1998, Mastering Delphi 4

Project: TABTEST.DPR


Project Structure


TABTEST.DPR

program Tabtest;

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

{$R *.RES}

begin
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

LISTSF.PAS

unit ListsF;

interface

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

type
  TForm1 = class(TForm)
    Md4TabbedList1: TMd4TabbedList;
    Edit1: TEdit;
    AddButton: TButton;
    Edit2: TEdit;
    Edit3: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Header1: THeader;
    procedure AddButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Header1Sized(Sender: TObject; ASection, AWidth: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.AddButtonClick(Sender: TObject);
var
  NewItem: String;
begin
  if Edit1.Text <> '' then
  begin
    NewItem := Edit1.Text + #9 + Edit2.Text +
      #9 + Edit3.Text;
    Md4TabbedList1.Items.Add (NewItem);
  end;
end;

const
  MaxNumSections = 9;

procedure TForm1.FormCreate(Sender: TObject);
var
  I, Last: Integer;
begin
  Last := 0;
  for I := 0 to Header1.Sections.Count - 1 do
  begin
    Last := Last + Header1.SectionWidth [I];
    Md4TabbedList1.TabStops [I] := Last;
  end;
  for I := Header1.Sections.Count to MaxNumSections do
    Md4TabbedList1.TabStops [I] := 1000;
end;

procedure TForm1.Header1Sized(Sender: TObject; ASection, AWidth: Integer);
var
  I, Last: Integer;
begin
  Last := 0;
  for I := 0 to Header1.Sections.Count - 1 do
  begin
    Last := Last + Header1.SectionWidth [I];
    Md4TabbedList1.TabStops [I] := Last;
  end;
end;

end.

LISTSF.DFM

object Form1: TForm1
  Left = 222
  Top = 96
  Width = 420
  Height = 400
  Caption = 'Tab Test'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBlack
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Label3: TLabel
    Left = 8
    Top = 272
    Width = 37
    Height = 13
    Caption = 'English:'
  end
  object Label4: TLabel
    Left = 8
    Top = 304
    Width = 40
    Height = 13
    Caption = 'Number:'
  end
  object Label5: TLabel
    Left = 8
    Top = 336
    Width = 31
    Height = 13
    Caption = 'Italian:'
  end
  object Md4TabbedList1: TMd4TabbedList
    Left = 0
    Top = 25
    Width = 412
    Height = 224
    Align = alTop
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -32
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ItemHeight = 37
    Items.Strings = (
      'one'#9'1'#9'uno'
          'two'#9'2'#9'due'
          'three'#9'3'#9'tre'
          'four'#9'4'#9'quattro'
          'five'#9'5'#9'cinque'
          'six'#9'6'#9'sei'
          'seven'#9'7'#9'sette'
          'eight'#9'8'#9'otto'
          'nine'#9'9'#9'nove'
          'ten'#9'10'#9'dieci'    )
    ParentFont = False
    TabOrder = 4
    TabsString = '0;0;0;0;0;0;0;0;0;0;'
  end
  object Edit1: TEdit
    Left = 96
    Top = 268
    Width = 185
    Height = 21
    TabOrder = 0
  end
  object AddButton: TButton
    Left = 310
    Top = 295
    Width = 81
    Height = 36
    Caption = 'Add'
    TabOrder = 3
    OnClick = AddButtonClick
  end
  object Edit2: TEdit
    Left = 96
    Top = 300
    Width = 185
    Height = 21
    TabOrder = 1
  end
  object Edit3: TEdit
    Left = 96
    Top = 332
    Width = 185
    Height = 21
    TabOrder = 2
  end
  object Header1: THeader
    Left = 0
    Top = 0
    Width = 412
    Height = 25
    Align = alTop
    Sections.Sections = (
      #0'99'#0'English'
        #0'100'#0'Number'
        #0'48'#0'Italian'  )
    TabOrder = 5
    OnSized = Header1Sized
  end
end


Copyright Marco Cantù 1998