This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEvilWorks.Vcl.Fullscreen.pas
109 lines (86 loc) · 2.02 KB
/
EvilWorks.Vcl.Fullscreen.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
unit EvilWorks.Vcl.Fullscreen;
interface
uses
WinApi.Windows,
System.Classes,
System.SysUtils,
Vcl.Forms;
type
TFullscreen = class(TComponent)
private
FShortcut : TShortcut;
FFullscreen : boolean;
FSaveRect : TRect;
FSaveBorderStyle: TFormBorderStyle;
public
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(aSource: TPersistent); override;
procedure EnterFullscreen;
procedure ExitFullscreen;
procedure ToggleFullscreen;
published
property Hotkey: TShortcut read FShortcut write FShortcut default VK_F11;
end;
implementation
{ TFullscreen }
constructor TFullscreen.Create(aOwner: TComponent);
begin
if (aOwner is TCustomForm = False) then
raise Exception.Create('TFullscreen owner must be placed on a TCustomForm descendant.');
inherited;
FShortcut := VK_F11;
end;
destructor TFullscreen.Destroy;
begin
inherited;
end;
procedure TFullscreen.EnterFullscreen;
begin
if (FFullscreen) then
Exit;
FSaveRect := TCustomForm(Owner).BoundsRect;
FSaveBorderStyle := TCustomForm(Owner).BorderStyle;
with (Owner as TCustomForm) do
begin
FSaveRect := BoundsRect;
FSaveBorderStyle := BorderStyle;
BorderStyle := bsNone;
Left := Screen.DesktopLeft;
Top := Screen.DesktopTop;
Width := Screen.DesktopWidth;
Height := Screen.DesktopHeight;
end;
FFullscreen := True;
end;
procedure TFullscreen.ExitFullscreen;
begin
if (FFullscreen = False) then
Exit;
with (Owner as TCustomForm) do
begin
BoundsRect := FSaveRect;
BorderStyle := FSaveBorderStyle;
Left := FSaveRect.Left;
Top := FSaveRect.Top;
Width := FSaveRect.Width;
Height := FSaveRect.Height;
end;
FFullscreen := False;
end;
procedure TFullscreen.ToggleFullscreen;
begin
if (FFullscreen) then
ExitFullscreen
else
EnterFullscreen;
end;
procedure TFullscreen.Assign(aSource: TPersistent);
begin
inherited;
if (aSource is TFullscreen) then
begin
Hotkey := TFullscreen(aSource).Hotkey;
end;
end;
end.