| 1 | {$INCLUDE Switches.inc}
|
|---|
| 2 | unit Back;
|
|---|
| 3 |
|
|---|
| 4 | interface
|
|---|
| 5 |
|
|---|
| 6 | uses
|
|---|
| 7 | LCLIntf, LCLType, SysUtils, Classes,
|
|---|
| 8 | {$IFDEF DPI}Dpi.Graphics, Dpi.Forms, Dpi.Controls{$ELSE}
|
|---|
| 9 | Graphics, Forms, Controls{$ENDIF};
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TBackground }
|
|---|
| 14 |
|
|---|
| 15 | TBackground = class(TForm)
|
|---|
| 16 | procedure FormDestroy(Sender: TObject);
|
|---|
| 17 | procedure FormPaint(Sender: TObject);
|
|---|
| 18 | procedure FormShow(Sender: TObject);
|
|---|
| 19 | procedure FormCreate(Sender: TObject);
|
|---|
| 20 | private
|
|---|
| 21 | Img: TBitmap;
|
|---|
| 22 | public
|
|---|
| 23 | procedure UpdateInterface;
|
|---|
| 24 | end;
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | implementation
|
|---|
| 28 |
|
|---|
| 29 | uses
|
|---|
| 30 | Directories, ScreenTools, Start;
|
|---|
| 31 |
|
|---|
| 32 | {$R *.lfm}
|
|---|
| 33 |
|
|---|
| 34 | procedure TBackground.FormCreate(Sender: TObject);
|
|---|
| 35 | begin
|
|---|
| 36 | Img := nil;
|
|---|
| 37 | end;
|
|---|
| 38 |
|
|---|
| 39 | procedure TBackground.FormShow(Sender: TObject);
|
|---|
| 40 | begin
|
|---|
| 41 | UpdateInterface;
|
|---|
| 42 | end;
|
|---|
| 43 |
|
|---|
| 44 | procedure TBackground.FormDestroy(Sender: TObject);
|
|---|
| 45 | begin
|
|---|
| 46 | if Assigned(Img) then FreeAndNil(Img);
|
|---|
| 47 | end;
|
|---|
| 48 |
|
|---|
| 49 | procedure TBackground.FormPaint(Sender: TObject);
|
|---|
| 50 | begin
|
|---|
| 51 | if Assigned(Img) and FullScreen then
|
|---|
| 52 | BitBltCanvas(Canvas, Width - Img.Width - (Width - 800) *
|
|---|
| 53 | 3 div 8, (Height - 600) div 3, Img.Width, Img.Height,
|
|---|
| 54 | Img.Canvas, 0, 0);
|
|---|
| 55 | end;
|
|---|
| 56 |
|
|---|
| 57 | procedure TBackground.UpdateInterface;
|
|---|
| 58 | var
|
|---|
| 59 | FileName: string;
|
|---|
| 60 | begin
|
|---|
| 61 | if FullScreen then begin
|
|---|
| 62 | BoundsRect := Screen.PrimaryMonitor.BoundsRect;
|
|---|
| 63 | WindowState := TWindowState.wsFullScreen;
|
|---|
| 64 | if not Assigned(Img) then begin
|
|---|
| 65 | FileName := GetGraphicsDir + DirectorySeparator + 'Background' + PngExt;
|
|---|
| 66 | if FileExists(FileName) then begin
|
|---|
| 67 | Img := TBitmap.Create;
|
|---|
| 68 | LoadGraphicFile(Img, FileName);
|
|---|
| 69 | Repaint;
|
|---|
| 70 | end;
|
|---|
| 71 | end;
|
|---|
| 72 | end else begin
|
|---|
| 73 | if WindowState <> TWindowState.wsMaximized then begin
|
|---|
| 74 | WindowState := TWindowState.wsNormal;
|
|---|
| 75 | WindowState := TWindowState.wsFullScreen;
|
|---|
| 76 | end;
|
|---|
| 77 | WindowState := TWindowState.wsNormal;
|
|---|
| 78 | BoundsRect := Bounds(StartDlg.Left - 8, StartDlg.Top - 8,
|
|---|
| 79 | StartDlg.Width + 16, StartDlg.Height + 16);
|
|---|
| 80 | end;
|
|---|
| 81 | end;
|
|---|
| 82 |
|
|---|
| 83 | end.
|
|---|