| 1 | unit UFormMain;
|
|---|
| 2 |
|
|---|
| 3 | {$mode objfpc}{$H+}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, UCompare,
|
|---|
| 9 | StdCtrls, Menus, ComCtrls, UFormPanel;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TFormMain }
|
|---|
| 14 |
|
|---|
| 15 | TFormMain = class(TForm)
|
|---|
| 16 | MainMenu1: TMainMenu;
|
|---|
| 17 | PanelMain: TPanel;
|
|---|
| 18 | StatusBar1: TStatusBar;
|
|---|
| 19 | procedure FormCreate(Sender: TObject);
|
|---|
| 20 | procedure FormDestroy(Sender: TObject);
|
|---|
| 21 | procedure FormResize(Sender: TObject);
|
|---|
| 22 | procedure SplitterChange(Sender: TObject);
|
|---|
| 23 | private
|
|---|
| 24 | Ratio: Double;
|
|---|
| 25 | public
|
|---|
| 26 | PanelLeft: TFormPanel;
|
|---|
| 27 | PanelRight: TFormPanel;
|
|---|
| 28 | Splitter: TSplitter;
|
|---|
| 29 | end;
|
|---|
| 30 |
|
|---|
| 31 | var
|
|---|
| 32 | FormMain: TFormMain;
|
|---|
| 33 |
|
|---|
| 34 | implementation
|
|---|
| 35 |
|
|---|
| 36 | {$R *.lfm}
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | { TFormMain }
|
|---|
| 40 |
|
|---|
| 41 | procedure TFormMain.FormCreate(Sender: TObject);
|
|---|
| 42 | begin
|
|---|
| 43 | Ratio := 0.5;
|
|---|
| 44 | PanelLeft := TFormPanel.Create(nil);
|
|---|
| 45 | PanelLeft.ManualDock(PanelMain, nil, alLeft);
|
|---|
| 46 | PanelLeft.Parent := PanelMain;
|
|---|
| 47 | PanelLeft.Align := alLeft;
|
|---|
| 48 | PanelLeft.Width := Width div 2;
|
|---|
| 49 | PanelLeft.Show;
|
|---|
| 50 | Splitter := TSplitter.Create(nil);
|
|---|
| 51 | Splitter.Parent := PanelMain;
|
|---|
| 52 | Splitter.Align := alLeft;
|
|---|
| 53 | Splitter.OnMoved := @SplitterChange;
|
|---|
| 54 | Splitter.Left := PanelLeft.Left + 1;
|
|---|
| 55 | Splitter.Show;
|
|---|
| 56 | PanelRight := TFormPanel.Create(nil);
|
|---|
| 57 | PanelRight.ManualDock(PanelMain, nil, alClient);
|
|---|
| 58 | PanelRight.Parent := PanelMain;
|
|---|
| 59 | PanelRight.Align := alClient;
|
|---|
| 60 | PanelRight.Show;
|
|---|
| 61 | end;
|
|---|
| 62 |
|
|---|
| 63 | procedure TFormMain.FormDestroy(Sender: TObject);
|
|---|
| 64 | begin
|
|---|
| 65 | FreeAndNil(PanelLeft);
|
|---|
| 66 | FreeAndNil(PanelRight);
|
|---|
| 67 | end;
|
|---|
| 68 |
|
|---|
| 69 | procedure TFormMain.FormResize(Sender: TObject);
|
|---|
| 70 | begin
|
|---|
| 71 | PanelLeft.Width := Round(Ratio * Width);
|
|---|
| 72 | end;
|
|---|
| 73 |
|
|---|
| 74 | procedure TFormMain.SplitterChange(Sender: TObject);
|
|---|
| 75 | begin
|
|---|
| 76 | Ratio := PanelLeft.Width / Width;
|
|---|
| 77 | end;
|
|---|
| 78 |
|
|---|
| 79 | end.
|
|---|
| 80 |
|
|---|