Changeset 548 for Common/UPersistentForm.pas
- Timestamp:
- Feb 12, 2021, 12:03:11 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/UPersistentForm.pas
r515 r548 3 3 {$mode delphi} 4 4 5 // Date: 20 15-04-185 // Date: 2020-11-26 6 6 7 7 interface … … 9 9 uses 10 10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls, 11 ExtCtrls ;11 ExtCtrls, LCLType; 12 12 13 13 type … … 26 26 FormRestoredSize: TRect; 27 27 FormWindowState: TWindowState; 28 FormFullScreen: Boolean; 28 29 Form: TForm; 29 30 procedure LoadFromRegistry(RegistryContext: TRegistryContext); … … 31 32 function CheckEntireVisible(Rect: TRect): TRect; 32 33 function CheckPartVisible(Rect: TRect; Part: Integer): TRect; 33 procedure Load(Form: TForm; DefaultMaximized: Boolean = False); 34 procedure Load(Form: TForm; DefaultMaximized: Boolean = False; 35 DefaultFullScreen: Boolean = False); 34 36 procedure Save(Form: TForm); 35 37 constructor Create(AOwner: TComponent); override; 38 procedure SetFullScreen(State: Boolean); 36 39 property RegistryContext: TRegistryContext read FRegistryContext 37 40 write FRegistryContext; … … 43 46 procedure Register; 44 47 48 45 49 implementation 46 47 50 48 51 procedure Register; … … 169 172 + FormRestoredSize.Top; 170 173 // Other state 171 FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(wsNormal))); 174 FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(FormWindowState))); 175 FormFullScreen := ReadBoolWithDefault('FullScreen', FormFullScreen); 172 176 finally 173 177 Free; … … 193 197 // Other state 194 198 WriteInteger('WindowState', Integer(FormWindowState)); 199 WriteBool('FullScreen', FormFullScreen); 195 200 finally 196 201 Free; … … 250 255 end; 251 256 252 procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False); 257 procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False; 258 DefaultFullScreen: Boolean = False); 253 259 begin 254 260 Self.Form := Form; … … 258 264 FormRestoredSize := Bounds((Screen.Width - Form.Width) div 2, 259 265 (Screen.Height - Form.Height) div 2, Form.Width, Form.Height); 266 FormWindowState := Form.WindowState; 267 FormFullScreen := DefaultFullScreen; 260 268 261 269 LoadFromRegistry(RegistryContext); … … 277 285 Form.BoundsRect := FormNormalSize; 278 286 end; 287 if FormFullScreen then SetFullScreen(True); 279 288 LoadControl(Form); 280 289 end; … … 284 293 Self.Form := Form; 285 294 FormNormalSize := Bounds(Form.Left, Form.Top, Form.Width, Form.Height); 286 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 287 Form.RestoredHeight); 295 if not FormFullScreen then 296 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 297 Form.RestoredHeight); 288 298 FormWindowState := Form.WindowState; 289 299 SaveToRegistry(RegistryContext); … … 300 310 end; 301 311 312 procedure TPersistentForm.SetFullScreen(State: Boolean); 313 begin 314 if State then begin 315 FormFullScreen := True; 316 FormNormalSize := Form.BoundsRect; 317 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 318 Form.RestoredHeight); 319 FormWindowState := Form.WindowState; 320 ShowWindow(Form.Handle, SW_SHOWFULLSCREEN); 321 {$IFDEF WINDOWS} 322 Form.BorderStyle := bsNone; 323 {$ENDIF} 324 end else begin 325 FormFullScreen := False; 326 {$IFDEF WINDOWS} 327 Form.BorderStyle := bsSizeable; 328 {$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; 337 end; 338 end; 339 302 340 end. 303 341
Note:
See TracChangeset
for help on using the changeset viewer.