Changeset 67 for branches/Independent/Os.pas
- Timestamp:
- Nov 2, 2024, 10:04:51 PM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Independent/Os.pas
r66 r67 22 22 TRunningApp = class 23 23 private 24 AppThread: TAppThread;25 24 FApp: TApp; 26 25 procedure SetApp(AValue: TApp); 27 26 public 28 27 Context: TAppContext; 28 AppThread: TAppThread; 29 29 procedure Run; 30 30 constructor Create; … … 37 37 TRunningApps = class(TObjectList<TRunningApp>) 38 38 function AddNew(App: TApp; System: TSystem): TRunningApp; 39 end;40 41 { TSystemApi }42 43 TSystemApi = class(TApi)44 private45 FName: string;46 FText: string;47 procedure WriteLineSync;48 procedure RunAppSync;49 public50 App: TRunningApp;51 System: TSystem;52 procedure WriteLine(Text: string); override;53 procedure RunApp(Name: string); override;54 procedure Sleep(Time: TDateTime); override;55 function CreateWindow: THandle; override;56 procedure SetWindowName(Handle: THandle; Name: string); override;57 procedure SetWindowRect(Handle: THandle; Rect: TRect); override;58 procedure SetWindowVisible(Handle: THandle; Visible: Boolean); override;59 39 end; 60 40 … … 80 60 private 81 61 FOnDraw: TNotifyEvent; 82 procedure Redraw;83 62 public 84 63 Console: TConsole; … … 88 67 Windows: TWindows; 89 68 Handles: THandles; 69 procedure Redraw; 90 70 procedure RunApp(Name: string); 91 71 procedure Start; … … 95 75 end; 96 76 77 97 78 implementation 98 79 99 80 uses 100 App s;81 AppCode, AppTest, SystemApi; 101 82 102 83 { TAppThread } … … 151 132 end; 152 133 153 { TSystemApi }154 155 procedure TSystemApi.WriteLineSync;156 begin157 System.Console.Write(App.App.Name + ': ' + FText);158 end;159 160 procedure TSystemApi.RunAppSync;161 begin162 System.RunApp(FName);163 end;164 165 procedure TSystemApi.WriteLine(Text: string);166 begin167 FText := Text;168 App.AppThread.Synchronize(WriteLineSync);169 end;170 171 procedure TSystemApi.RunApp(Name: string);172 begin173 FName := Name;174 App.AppThread.Synchronize(RunAppSync);175 end;176 177 procedure TSystemApi.Sleep(Time: TDateTime);178 begin179 App.AppThread.Sleep(Round(Time / OneMillisecond));180 end;181 182 function TSystemApi.CreateWindow: THandle;183 var184 Window: TWindow;185 begin186 Window := System.Windows.AddNew;187 Window.Handle := System.Handles.AddNew;188 Result := Window.Handle;189 end;190 191 procedure TSystemApi.SetWindowName(Handle: THandle; Name: string);192 var193 Window: TWindow;194 begin195 Window := System.Windows.SearchByHandle(Handle);196 if Assigned(Window) then begin197 Window.Name := Name;198 System.Redraw;199 end;200 end;201 202 procedure TSystemApi.SetWindowRect(Handle: THandle; Rect: TRect);203 var204 Window: TWindow;205 begin206 Window := System.Windows.SearchByHandle(Handle);207 if Assigned(Window) then begin208 Window.Rect := Rect;209 System.Redraw;210 end;211 end;212 213 procedure TSystemApi.SetWindowVisible(Handle: THandle; Visible: Boolean);214 var215 Window: TWindow;216 begin217 Window := System.Windows.SearchByHandle(Handle);218 if Assigned(Window) then begin219 Window.Visible := Visible;220 System.Redraw;221 end;222 end;223 224 134 { TWindows } 225 135
Note:
See TracChangeset
for help on using the changeset viewer.