Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Mastering Delphi 6

Chapter 07 - Project Split1

Project Structure

Split1.dpr
program Split1;

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

{$R *.RES}

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

interface

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

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    ListBox2: TListBox;
    ListBox3: TListBox;
    Splitter1: TSplitter;
    Splitter2: TSplitter;
    Panel1: TPanel;
    SpeedBeveled: TSpeedButton;
    SpeedColor: TSpeedButton;
    ColorDialog1: TColorDialog;
    LabelMin: TLabel;
    EditMin: TEdit;
    UpDownMin: TUpDown;
    LabelWidth: TLabel;
    EditWidth: TEdit;
    UpDownWidth: TUpDown;
    FontDialog1: TFontDialog;
    procedure SpeedBeveledClick(Sender: TObject);
    procedure SpeedColorClick(Sender: TObject);
    procedure UpDownMinClick(Sender: TObject; Button: TUDBtnType);
    procedure UpDownWidthClick(Sender: TObject; Button: TUDBtnType);
    procedure OnListClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.SpeedBeveledClick(Sender: TObject);
begin
  Splitter1.Beveled := SpeedBeveled.Down;
  Splitter2.Beveled := SpeedBeveled.Down;
end;

procedure TForm1.SpeedColorClick(Sender: TObject);
begin
  with ColorDialog1 do
    if Execute then
    begin
      Splitter1.Color := Color;
      Splitter2.Color := Color;
    end;
end;

procedure TForm1.UpDownMinClick(Sender: TObject; Button: TUDBtnType);
begin
  Splitter1.MinSize := UpDownMin.Position;
  Splitter2.MinSize := UpDownMin.Position;
end;

procedure TForm1.UpDownWidthClick(Sender: TObject; Button: TUDBtnType);
begin
  Splitter1.Width := UpDownWidth.Position;
  Splitter2.Width := UpDownWidth.Position;
end;

procedure TForm1.OnListClick(Sender: TObject);
begin
  with FontDialog1 do
    if Execute then
      (Sender as TListBox).Font := Font;
end;

end.
SplitFrm.dfm
object Form1: TForm1
  Left = 127
  Top = 101
  Width = 670
  Height = 479
  Caption = 'Split (with the Splitter component)'
  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 Splitter1: TSplitter
    Left = 280
    Top = 41
    Width = 3
    Height = 411
    Cursor = crHSplit
    AutoSnap = False
  end
  object Splitter2: TSplitter
    Left = 463
    Top = 41
    Width = 3
    Height = 411
    Cursor = crHSplit
    AutoSnap = False
  end
  object ListBox1: TListBox
    Left = 0
    Top = 41
    Width = 280
    Height = 411
    Align = alLeft
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -64
    Font.Name = 'Arial'
    Font.Style = []
    ItemHeight = 72
    Items.Strings = (
      'Whale'
      'Elephant'
      'Rhino'
      'Shark'
      'Giraffe')
    ParentFont = False
    TabOrder = 0
    OnDblClick = OnListClick
  end
  object ListBox2: TListBox
    Left = 283
    Top = 41
    Width = 180
    Height = 411
    Align = alLeft
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -32
    Font.Name = 'Arial'
    Font.Style = []
    ItemHeight = 36
    Items.Strings = (
      'Dog'
      'Cat'
      'Hen'
      'Monkey'
      'Cow'
      'Bull'
      'Hare'
      'Sheep')
    ParentFont = False
    TabOrder = 1
    OnDblClick = OnListClick
  end
  object ListBox3: TListBox
    Left = 466
    Top = 41
    Width = 196
    Height = 411
    Align = alClient
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -12
    Font.Name = 'Arial'
    Font.Style = []
    ItemHeight = 15
    Items.Strings = (
      'Lizard'
      'Ant'
      'Shrimp'
      'Bug'
      'Bee')
    ParentFont = False
    TabOrder = 2
    OnDblClick = OnListClick
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 662
    Height = 41
    Align = alTop
    TabOrder = 3
    object SpeedBeveled: TSpeedButton
      Left = 16
      Top = 8
      Width = 81
      Height = 25
      AllowAllUp = True
      GroupIndex = 1
      Caption = 'Beveled'
      OnClick = SpeedBeveledClick
    end
    object SpeedColor: TSpeedButton
      Left = 104
      Top = 8
      Width = 81
      Height = 25
      Caption = 'Color...'
      OnClick = SpeedColorClick
    end
    object LabelMin: TLabel
      Left = 200
      Top = 13
      Width = 40
      Height = 13
      Caption = 'MinSize:'
    end
    object LabelWidth: TLabel
      Left = 328
      Top = 12
      Width = 31
      Height = 13
      Caption = 'Width:'
    end
    object EditMin: TEdit
      Left = 256
      Top = 8
      Width = 41
      Height = 21
      ReadOnly = True
      TabOrder = 0
      Text = '30'
    end
    object UpDownMin: TUpDown
      Left = 297
      Top = 8
      Width = 15
      Height = 21
      Associate = EditMin
      Min = 10
      Max = 200
      Increment = 10
      Position = 30
      TabOrder = 1
      Wrap = False
      OnClick = UpDownMinClick
    end
    object EditWidth: TEdit
      Left = 368
      Top = 8
      Width = 49
      Height = 21
      ReadOnly = True
      TabOrder = 2
      Text = '3'
    end
    object UpDownWidth: TUpDown
      Left = 417
      Top = 8
      Width = 15
      Height = 21
      Associate = EditWidth
      Min = 1
      Position = 3
      TabOrder = 3
      Wrap = False
      OnClick = UpDownWidthClick
    end
  end
  object ColorDialog1: TColorDialog
    Ctl3D = True
    Left = 24
    Top = 72
  end
  object FontDialog1: TFontDialog
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    MinFontSize = 0
    MaxFontSize = 0
    Left = 24
    Top = 128
  end
end