Changeset 69


Ignore:
Timestamp:
Nov 28, 2020, 12:35:06 PM (4 years ago)
Author:
chronos
Message:
  • Fixed: Restore from fulscreen mode to maximized state not retaining normal state dimensions.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r68 r69  
    7373procedure TFormMain.FormActivate(Sender: TObject);
    7474begin
     75end;
     76
     77procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     78begin
     79  PersistentForm1.Save(Self);
     80end;
     81
     82procedure TFormMain.FormDestroy(Sender: TObject);
     83begin
     84  SaveConfig;
     85  Engine.Free;
     86end;
     87
     88procedure TFormMain.FormKeyPress(Sender: TObject; var Key: char);
     89begin
     90  if Key = #32 then begin
     91    if Engine.State = gsRunning then Engine.State := gsPaused
     92    else if Engine.State = gsPaused then Engine.State := gsRunning;
     93  end;
     94end;
     95
     96procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
     97  );
     98const
     99  KeyF11 = 122;
     100begin
     101  if Key = KeyF11 then begin
     102    FullScreen := not FullScreen;
     103    PersistentForm1.SetFullScreen(FormMain.FullScreen);
     104  end else
     105    Engine.KeyUp(Key);
     106end;
     107
     108procedure TFormMain.FormShow(Sender: TObject);
     109begin
    75110  if not Initialized then begin
    76111    Initialized := True;
     
    78113    PersistentForm1.Load(Self, False, True);
    79114    FullScreen := PersistentForm1.FormFullScreen;
    80     Randomize;
    81115    Engine.InitMenus;
    82116    Engine.ImagePassenger.Picture.Assign(FormImages.ImagePassenger.Picture);
     
    86120    Engine.MainMenu;
    87121  end;
    88 end;
    89 
    90 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    91 begin
    92   PersistentForm1.Save(Self);
    93 end;
    94 
    95 procedure TFormMain.FormDestroy(Sender: TObject);
    96 begin
    97   SaveConfig;
    98   Engine.Free;
    99 end;
    100 
    101 procedure TFormMain.FormKeyPress(Sender: TObject; var Key: char);
    102 begin
    103   if Key = #32 then begin
    104     if Engine.State = gsRunning then Engine.State := gsPaused
    105     else if Engine.State = gsPaused then Engine.State := gsRunning;
    106   end;
    107 end;
    108 
    109 procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
    110   );
    111 const
    112   KeyF11 = 122;
    113 begin
    114   if Key = KeyF11 then begin
    115     FullScreen := not FullScreen;
    116     PersistentForm1.SetFullScreen(FormMain.FullScreen);
    117   end else
    118     Engine.KeyUp(Key);
    119 end;
    120 
    121 procedure TFormMain.FormShow(Sender: TObject);
    122 begin
    123122end;
    124123
  • trunk/Packages/Common/UPersistentForm.pas

    r68 r69  
    314314  if State then begin
    315315    FormFullScreen := True;
     316    FormNormalSize := Form.BoundsRect;
    316317    FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth,
    317318      Form.RestoredHeight);
     319    FormWindowState := Form.WindowState;
    318320    ShowWindow(Form.Handle, SW_SHOWFULLSCREEN);
    319321    {$IFDEF WINDOWS}
     
    322324  end else begin
    323325    FormFullScreen := False;
    324     if Form.WindowState = wsNormal then begin
    325       ShowWindow(Form.Handle, SW_SHOWNORMAL);
    326       //Form.BoundsRect := FormRestoredSize;
    327     end else if Form.WindowState = wsMaximized then ShowWindow(Form.Handle, SW_SHOWMAXIMIZED);
    328326    {$IFDEF WINDOWS}
    329327    Form.BorderStyle := bsSizeable;
    330328    {$ENDIF}
     329    ShowWindow(Form.Handle, SW_SHOWNORMAL);
     330    if FormWindowState = wsNormal then begin
     331      Form.BoundsRect := FormNormalSize;
     332    end else
     333    if FormWindowState = wsMaximized then begin
     334      Form.BoundsRect := FormRestoredSize;
     335      Form.WindowState := wsMaximized;
     336    end;
    331337  end;
    332338end;
Note: See TracChangeset for help on using the changeset viewer.