| 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 | var
|
|---|
| 27 | Background: TBackground;
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | implementation
|
|---|
| 31 |
|
|---|
| 32 | uses
|
|---|
| 33 | Directories, ScreenTools, Start;
|
|---|
| 34 |
|
|---|
| 35 | {$R *.lfm}
|
|---|
| 36 |
|
|---|
| 37 | procedure TBackground.FormCreate(Sender: TObject);
|
|---|
| 38 | begin
|
|---|
| 39 | Img := nil;
|
|---|
| 40 | end;
|
|---|
| 41 |
|
|---|
| 42 | procedure TBackground.FormShow(Sender: TObject);
|
|---|
| 43 | begin
|
|---|
| 44 | UpdateInterface;
|
|---|
| 45 | end;
|
|---|
| 46 |
|
|---|
| 47 | procedure TBackground.FormDestroy(Sender: TObject);
|
|---|
| 48 | begin
|
|---|
| 49 | if Assigned(Img) then FreeAndNil(Img);
|
|---|
| 50 | end;
|
|---|
| 51 |
|
|---|
| 52 | procedure TBackground.FormPaint(Sender: TObject);
|
|---|
| 53 | begin
|
|---|
| 54 | if Assigned(Img) then
|
|---|
| 55 | BitBltCanvas(Canvas, Width - Img.Width - (Width - 800) *
|
|---|
| 56 | 3 div 8, (Height - 600) div 3, Img.Width, Img.Height,
|
|---|
| 57 | Img.Canvas, 0, 0);
|
|---|
| 58 | end;
|
|---|
| 59 |
|
|---|
| 60 | procedure TBackground.UpdateInterface;
|
|---|
| 61 | var
|
|---|
| 62 | FileName: string;
|
|---|
| 63 | begin
|
|---|
| 64 | if FullScreen then begin
|
|---|
| 65 | BoundsRect := Screen.PrimaryMonitor.BoundsRect;
|
|---|
| 66 | WindowState := TWindowState.wsFullScreen;
|
|---|
| 67 | if not Assigned(Img) then begin
|
|---|
| 68 | FileName := GetGraphicsDir + DirectorySeparator + 'Background.png';
|
|---|
| 69 | if FileExists(FileName) then begin
|
|---|
| 70 | Img := TBitmap.Create;
|
|---|
| 71 | LoadGraphicFile(Img, FileName);
|
|---|
| 72 | Repaint;
|
|---|
| 73 | end;
|
|---|
| 74 | end;
|
|---|
| 75 | end else begin
|
|---|
| 76 | if WindowState <> TWindowState.wsMaximized then begin
|
|---|
| 77 | WindowState := TWindowState.wsNormal;
|
|---|
| 78 | WindowState := TWindowState.wsFullScreen;
|
|---|
| 79 | end;
|
|---|
| 80 | WindowState := TWindowState.wsNormal;
|
|---|
| 81 | BoundsRect := Bounds(StartDlg.Left - 8, StartDlg.Top - 8,
|
|---|
| 82 | StartDlg.Width + 16, StartDlg.Height + 16);
|
|---|
| 83 | end;
|
|---|
| 84 | end;
|
|---|
| 85 |
|
|---|
| 86 | end.
|
|---|