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