source: tags/1.2.0/Back.pas

Last change on this file was 220, checked in by chronos, 4 years ago
  • Modified: Use wsFullScreen to switch to fullscreen mode.
  • Fixed: Image memory leak in TechTree.
File size: 1.8 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 end;
74 end;
75 end else begin
76 WindowState := wsNormal;
77 BoundsRect := Bounds(StartDlg.Left - 8, StartDlg.Top - 8,
78 StartDlg.Width + 16, StartDlg.Height + 16);
79 end;
80end;
81
82end.
Note: See TracBrowser for help on using the repository browser.