source: tags/1.3.6/Back.pas

Last change on this file was 623, checked in by chronos, 2 months ago
  • Modified: Avoid using screen size in Background painting.
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
26var
27 Background: TBackground;
28
29
30implementation
31
32uses
33 Directories, ScreenTools, Start;
34
35{$R *.lfm}
36
37procedure TBackground.FormCreate(Sender: TObject);
38begin
39 Img := nil;
40end;
41
42procedure TBackground.FormShow(Sender: TObject);
43begin
44 UpdateInterface;
45end;
46
47procedure TBackground.FormDestroy(Sender: TObject);
48begin
49 if Assigned(Img) then FreeAndNil(Img);
50end;
51
52procedure TBackground.FormPaint(Sender: TObject);
53begin
54 if Assigned(Img) then
55 BitBltCanvas(Canvas, Width - Img.Width - (Width - 800) *
56 3 div 8, (Height - 600) div 3, Img.Width, Img.Height,
57 Img.Canvas, 0, 0);
58end;
59
60procedure TBackground.UpdateInterface;
61var
62 FileName: string;
63begin
64 if FullScreen then begin
65 BoundsRect := Screen.PrimaryMonitor.BoundsRect;
66 WindowState := TWindowState.wsFullScreen;
67 if not Assigned(Img) then begin
68 FileName := GetGraphicsDir + DirectorySeparator + 'Background.png';
69 if FileExists(FileName) then begin
70 Img := TBitmap.Create;
71 LoadGraphicFile(Img, FileName);
72 Repaint;
73 end;
74 end;
75 end else begin
76 if WindowState <> TWindowState.wsMaximized then begin
77 WindowState := TWindowState.wsNormal;
78 WindowState := TWindowState.wsFullScreen;
79 end;
80 WindowState := TWindowState.wsNormal;
81 BoundsRect := Bounds(StartDlg.Left - 8, StartDlg.Top - 8,
82 StartDlg.Width + 16, StartDlg.Height + 16);
83 end;
84end;
85
86end.
Note: See TracBrowser for help on using the repository browser.