Changeset 99 for trunk/Packages/Common


Ignore:
Timestamp:
Jul 19, 2024, 11:05:07 PM (4 months ago)
Author:
chronos
Message:
  • Fixed: Full screen mode switching.
Location:
trunk/Packages/Common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Common.pas

    r85 r99  
    5353function ComputerName: string;
    5454procedure DeleteFiles(APath, AFileSpec: string);
     55function EndsWith(Text, What: string): Boolean;
    5556function Explode(Separator: Char; Data: string): TStringArray;
    5657procedure ExecuteProgram(Executable: string; Parameters: array of string);
     
    8788procedure SearchFiles(AList: TStrings; Dir: string;
    8889  FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil);
     90procedure SortStrings(Strings: TStrings);
    8991function SplitString(var Text: string; Count: Word): string;
    9092function StripTags(const S: string): string;
     93function StartsWith(Text, What: string): Boolean;
    9194function TryHexToInt(Data: string; out Value: Integer): Boolean;
    9295function TryBinToInt(Data: string; out Value: Integer): Boolean;
    93 procedure SortStrings(Strings: TStrings);
    9496
    9597
    9698implementation
     99
     100function StartsWith(Text, What: string): Boolean;
     101begin
     102  Result := Copy(Text, 1, Length(Text)) = What;
     103end;
     104
     105function EndsWith(Text, What: string): Boolean;
     106begin
     107  Result := Copy(Text, Length(Text) - Length(What) + 1, MaxInt) = What;
     108end;
    97109
    98110function BinToInt(BinStr : string) : Int64;
  • trunk/Packages/Common/FormEx.pas

    r88 r99  
    1313  private
    1414    FCounter: Integer; static;
     15    FFirstShow: Boolean;
    1516  protected
    1617    procedure DoShow; override;
     
    1920    procedure DoDestroy; override;
    2021  public
     22    FullScreen: Boolean;
    2123    PersistentForm: TPersistentForm; static;
    2224    ThemeManager: TThemeManager; static;
     
    4446begin
    4547  inherited;
    46   PersistentForm.Load(Self);
     48  if not FFirstShow and (not (csDesigning in ComponentState)) then begin
     49    FFirstShow := True;
     50    PersistentForm.Load(Self);
     51    FullScreen := PersistentForm.FormFullScreen;
     52  end;
    4753end;
    4854
     
    7682procedure TFormEx.DoClose(var CloseAction: TCloseAction);
    7783begin
    78   PersistentForm.Save(Self);
     84  if  (not (csDesigning in ComponentState)) then begin
     85    PersistentForm.FormFullScreen := FullScreen;
     86    PersistentForm.Save(Self);
     87  end;
    7988  inherited;
    8089end;
  • trunk/Packages/Common/PersistentForm.pas

    r85 r99  
    1616    FMinVisiblePart: Integer;
    1717    FRegistryContext: TRegistryContext;
     18    FResizeEventOccured: Boolean;
    1819    procedure LoadControl(Control: TControl);
    1920    procedure SaveControl(Control: TControl);
     21    procedure WindowStateChange(Sender: TObject);
    2022  public
    2123    FormRestoredSize: TRect;
     
    301303
    302304procedure TPersistentForm.SetFullScreen(State: Boolean);
     305{$IFDEF UNIX}
     306var
     307  OldHandler: TNotifyEvent;
     308var
     309  I: Integer;
     310{$ENDIF}
    303311begin
    304312  if State then begin
     
    312320    end;
    313321    FormWindowState := Form.WindowState;
    314     Form.WindowState := wsMaximized;
    315     Form.WindowState := wsNormal;
    316     ShowWindow(Form.Handle, SW_SHOWFULLSCREEN);
    317322    {$IFDEF WINDOWS}
    318323    Form.BorderStyle := bsNone;
    319324    {$ENDIF}
     325    Form.WindowState := wsFullscreen;
     326    {$IFDEF UNIX}
     327    // Workaround on Linux, WindowState is rewriten by WMSize event to wsNormal.
     328    // We need for that even to occure
     329    OldHandler := Form.OnWindowStateChange;
     330    Form.OnWindowStateChange := WindowStateChange;
     331    FResizeEventOccured := False;
     332    for I := 0 to 10 do begin
     333      if FResizeEventOccured then Break;
     334      Application.ProcessMessages;
     335      Sleep(1);
     336    end;
     337    Form.OnWindowStateChange := OldHandler;
     338    {$ENDIF}
    320339  end else begin
    321340    FormFullScreen := False;
     341    Form.WindowState := wsNormal;
    322342    {$IFDEF WINDOWS}
    323343    Form.BorderStyle := bsSizeable;
    324344    {$ENDIF}
    325     ShowWindow(Form.Handle, SW_SHOWNORMAL);
    326345    if FormWindowState = wsNormal then begin
    327346      Form.WindowState := wsNormal;
     
    335354end;
    336355
     356procedure TPersistentForm.WindowStateChange(Sender: TObject);
     357begin
     358  Form.WindowState := wsFullscreen;
     359  FResizeEventOccured := True;
     360end;
     361
    337362end.
Note: See TracChangeset for help on using the changeset viewer.