source: trunk/Back.pas

Last change on this file was 732, checked in by chronos, 3 months ago
  • Modified: Background form belongs to Start screen. Changed from global variable to local variable of StartDlg.
File size: 1.9 KB
Line 
1{$INCLUDE Switches.inc}
2unit Back;
3
4interface
5
6uses
7 LCLIntf, LCLType, SysUtils, Classes,
8 {$IFDEF DPI}Dpi.Graphics, Dpi.Forms, Dpi.Controls{$ELSE}
9 Graphics, Forms, Controls{$ENDIF};
10
11type
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
27implementation
28
29uses
30 Directories, ScreenTools, Start;
31
32{$R *.lfm}
33
34procedure TBackground.FormCreate(Sender: TObject);
35begin
36 Img := nil;
37end;
38
39procedure TBackground.FormShow(Sender: TObject);
40begin
41 UpdateInterface;
42end;
43
44procedure TBackground.FormDestroy(Sender: TObject);
45begin
46 if Assigned(Img) then FreeAndNil(Img);
47end;
48
49procedure TBackground.FormPaint(Sender: TObject);
50begin
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);
55end;
56
57procedure TBackground.UpdateInterface;
58var
59 FileName: string;
60begin
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;
81end;
82
83end.
Note: See TracBrowser for help on using the repository browser.