Marco Cantù 1998, Mastering Delphi 4

Project: SPLITH.DPR


Project Structure


SPLITH.DPR

program SplitH;

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

{$R *.RES}

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

SPLITHF.PAS

unit SplitHF;

interface

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

type
  TForm1 = class(TForm)
    MemoUp: TMemo;
    Splitter1: TSplitter;
    MemoDown: TMemo;
    OpenDialog1: TOpenDialog;
    StatusBar1: TStatusBar;
    procedure Splitter1Moved(Sender: TObject);
    procedure MemoDblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Splitter1Moved(Sender: TObject);
begin
  StatusBar1.Panels[0].Text := Format (
    'Upper Memo: %d - Lower Memo: %d',
    [MemoUp.Height, MemoDown.Height]);
 end;

procedure TForm1.MemoDblClick(Sender: TObject);
begin
  with Sender as TMemo, OpenDialog1 do
    if Execute then
      Lines.LoadFromFile (FileName);
end;

end.

SPLITHF.DFM

object Form1: TForm1
  Left = 41
  Top = 89
  Width = 721
  Height = 529
  Caption = 'Horizontal Splitter'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  OnResize = Splitter1Moved
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 0
    Top = 200
    Width = 713
    Height = 5
    Cursor = crVSplit
    Align = alTop
    OnMoved = Splitter1Moved
  end
  object MemoUp: TMemo
    Left = 0
    Top = 0
    Width = 713
    Height = 200
    Align = alTop
    ScrollBars = ssVertical
    TabOrder = 0
    OnDblClick = MemoDblClick
  end
  object MemoDown: TMemo
    Left = 0
    Top = 205
    Width = 713
    Height = 278
    Align = alClient
    ScrollBars = ssVertical
    TabOrder = 1
    OnDblClick = MemoDblClick
  end
  object StatusBar1: TStatusBar
    Left = 0
    Top = 483
    Width = 713
    Height = 19
    Panels = <
      item
        Width = 50
      end>
    SimplePanel = False
  end
  object OpenDialog1: TOpenDialog
    Filter = 'Text file (*.txt)|*.txt|Any file (*.*)|*.*'
    Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist]
    Left = 40
    Top = 32
  end
end


Copyright Marco Cantù 1998