source: branches/Independent/Forms/FormMain.pas

Last change on this file was 66, checked in by chronos, 6 weeks ago
  • Added: Api calls to show windows.
File size: 2.4 KB
Line 
1unit FormMain;
2
3interface
4
5uses
6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
7 ActnList, ExtCtrls, Os, FormConsole, FormScreen;
8
9type
10
11 { TFormName }
12
13 TFormName = class(TForm)
14 AConsole: TAction;
15 AFullscreen: TAction;
16 AExit: TAction;
17 ActionList1: TActionList;
18 MainMenu1: TMainMenu;
19 MenuItem1: TMenuItem;
20 MenuItem2: TMenuItem;
21 MenuItem3: TMenuItem;
22 MenuItem4: TMenuItem;
23 MenuItem5: TMenuItem;
24 MenuItemView: TMenuItem;
25 procedure AConsoleExecute(Sender: TObject);
26 procedure AExitExecute(Sender: TObject);
27 procedure AFullscreenExecute(Sender: TObject);
28 procedure FormCreate(Sender: TObject);
29 procedure FormDestroy(Sender: TObject);
30 procedure FormShow(Sender: TObject);
31 private
32 FileSystemDir: string;
33 System: TSystem;
34 procedure ConsoleWrite(Text: string);
35 function LoadFile(Name: string): string;
36 public
37 FormConsole: TFormConsole;
38 FormScreen: TFormScreen;
39 end;
40
41var
42 FormName: TFormName;
43
44
45implementation
46
47{$R *.lfm}
48
49{ TFormName }
50
51procedure TFormName.FormShow(Sender: TObject);
52begin
53 FormScreen.ManualDock(Self, nil, alClient);
54 FormScreen.Align := alClient;
55 FormScreen.Show;
56
57 System := TSystem.Create;
58 System.Console.OnWrite := ConsoleWrite;
59 System.FileSystem.OnLoadFile := LoadFile;
60 System.OnDraw := FormScreen.Redraw;
61 FormScreen.System := System;
62
63 System.Start;
64end;
65
66procedure TFormName.FormCreate(Sender: TObject);
67begin
68 FileSystemDir := 'FileSystem';
69 FormConsole := TFormConsole.Create(nil);
70 FormScreen := TFormScreen.Create(nil);
71end;
72
73procedure TFormName.FormDestroy(Sender: TObject);
74begin
75 FreeAndNil(System);
76 FreeAndNil(FormConsole);
77 FreeAndNil(FormScreen);
78end;
79
80procedure TFormName.AExitExecute(Sender: TObject);
81begin
82 Close;
83 Application.Terminate;
84end;
85
86procedure TFormName.AConsoleExecute(Sender: TObject);
87begin
88 FormConsole.Show;
89end;
90
91procedure TFormName.AFullscreenExecute(Sender: TObject);
92begin
93
94end;
95
96procedure TFormName.ConsoleWrite(Text: string);
97begin
98 FormConsole.Memo1.Lines.Add(Text);
99end;
100
101function TFormName.LoadFile(Name: string): string;
102var
103 F: TFileStream;
104begin
105 F := TFileStream.Create(FileSystemDir + DirectorySeparator + Name, fmOpenRead);
106 try
107 if F.Size > 0 then begin
108 Result := default(string);
109 SetLength(Result, F.Size);
110 F.Read(Result[1], F.Size);
111 end else Result := '';
112 finally
113 F.Free;
114 end;
115end;
116
117end.
118
Note: See TracBrowser for help on using the repository browser.