source: branches/highdpi/Back.pas

Last change on this file was 467, checked in by chronos, 5 months ago
  • Modified: DpiControls unit split into multiple units according to their LCL names.
File size: 1.9 KB
Line 
1{$INCLUDE Switches.inc}
2unit Back;
3
4interface
5
6uses
7 Dpi.Forms, Dpi.Graphics,
8 LCLIntf, LCLType, SysUtils, Classes, Graphics, Forms, Controls;
9
10type
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
26var
27 Background: TBackground;
28
29implementation
30
31uses
32 Directories, ScreenTools, Start;
33
34{$R *.lfm}
35
36procedure TBackground.FormCreate(Sender: TObject);
37begin
38 Img := nil;
39end;
40
41procedure TBackground.FormShow(Sender: TObject);
42begin
43 UpdateInterface;
44end;
45
46procedure TBackground.FormDestroy(Sender: TObject);
47begin
48 if Assigned(Img) then FreeAndNil(Img);
49end;
50
51procedure TBackground.FormPaint(Sender: TObject);
52begin
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);
57end;
58
59procedure TBackground.FormClose(Sender: TObject; var Action: TCloseAction);
60begin
61end;
62
63procedure TBackground.UpdateInterface;
64var
65 FileName: string;
66begin
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;
86end;
87
88end.
Note: See TracBrowser for help on using the repository browser.