source: tags/1.3.1/Back.pas

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