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 07 - Project Splith

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 = 116
  Top = 127
  Width = 613
  Height = 387
  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 = 177
    Width = 605
    Height = 5
    Cursor = crVSplit
    HelpType = htKeyword
    Align = alTop
    OnMoved = Splitter1Moved
  end
  object MemoUp: TMemo
    Left = 0
    Top = 0
    Width = 605
    Height = 177
    Align = alTop
    Constraints.MinHeight = 50
    ScrollBars = ssVertical
    TabOrder = 0
    OnDblClick = MemoDblClick
  end
  object MemoDown: TMemo
    Left = 0
    Top = 182
    Width = 605
    Height = 159
    Align = alClient
    Constraints.MinHeight = 50
    ScrollBars = ssVertical
    TabOrder = 1
    OnDblClick = MemoDblClick
  end
  object StatusBar1: TStatusBar
    Left = 0
    Top = 341
    Width = 605
    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