Changeset 66 for branches/Independent/Os.pas
- Timestamp:
- Oct 10, 2024, 11:05:35 PM (11 days ago)
- Location:
- branches/Independent
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Independent
- Property svn:ignore
-
old new 3 3 Independent.lps 4 4 Independent.res 5 heaptrclog.trc
-
- Property svn:ignore
-
branches/Independent/Os.pas
r65 r66 53 53 procedure RunApp(Name: string); override; 54 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 end; 60 61 { TWindow } 62 63 TWindow = class 64 Handle: THandle; 65 Name: string; 66 Visible: Boolean; 67 Rect: TRect; 68 end; 69 70 { TWindows } 71 72 TWindows = class(TObjectList<TWindow>) 73 function AddNew: TWindow; 74 function SearchByHandle(Handle: THandle): TWindow; 55 75 end; 56 76 … … 58 78 59 79 TSystem = class 80 private 81 FOnDraw: TNotifyEvent; 82 procedure Redraw; 83 public 60 84 Console: TConsole; 61 85 FileSystem: TFileSystem; 62 86 Apps: TApps; 63 87 RunningApps: TRunningApps; 88 Windows: TWindows; 89 Handles: THandles; 64 90 procedure RunApp(Name: string); 65 91 procedure Start; 66 92 constructor Create; 67 93 destructor Destroy; override; 94 property OnDraw: TNotifyEvent read FOnDraw write FOnDraw; 68 95 end; 69 96 … … 153 180 end; 154 181 182 function TSystemApi.CreateWindow: THandle; 183 var 184 Window: TWindow; 185 begin 186 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 var 193 Window: TWindow; 194 begin 195 Window := System.Windows.SearchByHandle(Handle); 196 if Assigned(Window) then begin 197 Window.Name := Name; 198 System.Redraw; 199 end; 200 end; 201 202 procedure TSystemApi.SetWindowRect(Handle: THandle; Rect: TRect); 203 var 204 Window: TWindow; 205 begin 206 Window := System.Windows.SearchByHandle(Handle); 207 if Assigned(Window) then begin 208 Window.Rect := Rect; 209 System.Redraw; 210 end; 211 end; 212 213 procedure TSystemApi.SetWindowVisible(Handle: THandle; Visible: Boolean); 214 var 215 Window: TWindow; 216 begin 217 Window := System.Windows.SearchByHandle(Handle); 218 if Assigned(Window) then begin 219 Window.Visible := Visible; 220 System.Redraw; 221 end; 222 end; 223 224 { TWindows } 225 226 function TWindows.AddNew: TWindow; 227 begin 228 Result := TWindow.Create; 229 Add(Result); 230 end; 231 232 function TWindows.SearchByHandle(Handle: THandle): TWindow; 233 var 234 I: Integer; 235 begin 236 I := 0; 237 while (I < Count) and (Items[I].Handle <> Handle) do Inc(I); 238 if I < Count then Result := Items[I] 239 else Result := nil; 240 end; 241 155 242 { TSystem } 243 244 procedure TSystem.Redraw; 245 begin 246 if Assigned(FOnDraw) then FOnDraw(Self); 247 end; 156 248 157 249 procedure TSystem.RunApp(Name: string); … … 182 274 constructor TSystem.Create; 183 275 begin 276 Handles := THandles.Create; 277 Windows := TWindows.Create; 184 278 Console := TConsole.Create; 185 279 FileSystem := TFileSystem.Create; … … 194 288 FreeAndNil(Console); 195 289 FreeAndNil(FileSystem); 290 FreeAndNil(Windows); 291 FreeAndNil(Handles); 196 292 inherited; 197 293 end;
Note:
See TracChangeset
for help on using the changeset viewer.