Ignore:
Timestamp:
Oct 10, 2024, 11:05:35 PM (11 days ago)
Author:
chronos
Message:
  • Added: Api calls to show windows.
Location:
branches/Independent
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/Independent

    • Property svn:ignore
      •  

        old new  
        33Independent.lps
        44Independent.res
         5heaptrclog.trc
  • branches/Independent/Os.pas

    r65 r66  
    5353    procedure RunApp(Name: string); override;
    5454    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;
    5575  end;
    5676
     
    5878
    5979  TSystem = class
     80  private
     81    FOnDraw: TNotifyEvent;
     82    procedure Redraw;
     83  public
    6084    Console: TConsole;
    6185    FileSystem: TFileSystem;
    6286    Apps: TApps;
    6387    RunningApps: TRunningApps;
     88    Windows: TWindows;
     89    Handles: THandles;
    6490    procedure RunApp(Name: string);
    6591    procedure Start;
    6692    constructor Create;
    6793    destructor Destroy; override;
     94    property OnDraw: TNotifyEvent read FOnDraw write FOnDraw;
    6895  end;
    6996
     
    153180end;
    154181
     182function TSystemApi.CreateWindow: THandle;
     183var
     184  Window: TWindow;
     185begin
     186  Window := System.Windows.AddNew;
     187  Window.Handle := System.Handles.AddNew;
     188  Result := Window.Handle;
     189end;
     190
     191procedure TSystemApi.SetWindowName(Handle: THandle; Name: string);
     192var
     193  Window: TWindow;
     194begin
     195  Window := System.Windows.SearchByHandle(Handle);
     196  if Assigned(Window) then begin
     197    Window.Name := Name;
     198    System.Redraw;
     199  end;
     200end;
     201
     202procedure TSystemApi.SetWindowRect(Handle: THandle; Rect: TRect);
     203var
     204  Window: TWindow;
     205begin
     206  Window := System.Windows.SearchByHandle(Handle);
     207  if Assigned(Window) then begin
     208    Window.Rect := Rect;
     209    System.Redraw;
     210  end;
     211end;
     212
     213procedure TSystemApi.SetWindowVisible(Handle: THandle; Visible: Boolean);
     214var
     215  Window: TWindow;
     216begin
     217  Window := System.Windows.SearchByHandle(Handle);
     218  if Assigned(Window) then begin
     219    Window.Visible := Visible;
     220    System.Redraw;
     221  end;
     222end;
     223
     224{ TWindows }
     225
     226function TWindows.AddNew: TWindow;
     227begin
     228  Result := TWindow.Create;
     229  Add(Result);
     230end;
     231
     232function TWindows.SearchByHandle(Handle: THandle): TWindow;
     233var
     234  I: Integer;
     235begin
     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;
     240end;
     241
    155242{ TSystem }
     243
     244procedure TSystem.Redraw;
     245begin
     246  if Assigned(FOnDraw) then FOnDraw(Self);
     247end;
    156248
    157249procedure TSystem.RunApp(Name: string);
     
    182274constructor TSystem.Create;
    183275begin
     276  Handles := THandles.Create;
     277  Windows := TWindows.Create;
    184278  Console := TConsole.Create;
    185279  FileSystem := TFileSystem.Create;
     
    194288  FreeAndNil(Console);
    195289  FreeAndNil(FileSystem);
     290  FreeAndNil(Windows);
     291  FreeAndNil(Handles);
    196292  inherited;
    197293end;
Note: See TracChangeset for help on using the changeset viewer.