-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUnit1.pas
236 lines (212 loc) · 5.99 KB
/
Unit1.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.Buttons, Vcl.StdCtrls, Vcl.Imaging.pngimage, Vcl.ExtCtrls, Vcl.ComCtrls,
Vcl.Imaging.jpeg
;
type
TRoundedForm = class(TForm)
pnlNav: TPanel;
pnlMain: TPanel;
Panel1: TPanel;
Panel2: TPanel;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Label3: TLabel;
Shape1: TShape;
Edit1: TEdit;
Panel3: TPanel;
Panel4: TPanel;
Label4: TLabel;
Label5: TLabel;
Image2: TImage;
Label6: TLabel;
Label7: TLabel;
Image3: TImage;
Panel5: TPanel;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
Label8: TLabel;
Panel6: TPanel;
Image4: TImage;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Panel7: TPanel;
Image5: TImage;
Panel8: TPanel;
Image6: TImage;
Image7: TImage;
Image8: TImage;
Image9: TImage;
Image11: TImage;
ProgressBar1: TProgressBar;
procedure FormCreate(Sender: TObject);
procedure WMMouseMove(var Msg : TWMMouseMove); message WM_MOUSEMOVE;
procedure WMNCMouseLeave(var Msg : TMessage); message WM_NCMOUSELEAVE;
procedure WMNCButtonDown(var Msg : TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
procedure WMNCButtonUp(var Msg : TWMNCLButtonUp); message WM_NCLBUTTONUP;
procedure WMSYSCommand(var Msg : TWMSysCommand); message WM_SYSCOMMAND;
procedure pnlMainMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure pnlMainMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure SpeedButton6Click(Sender: TObject);
private
{ Private-Deklarationen }
FRgnHandle : HRGN;
FRgnTop : Integer;
FRgnBottom : Integer;
FRgnRight : Integer;
FRgnLeft : Integer;
FRgnCorner : Integer;
FMouseLeaveCount : Integer;
FNCLButtonDown : Boolean;
FMousePoint: TPoint;
FFormPoint: TPoint;
procedure DeleteRegion;
procedure CreateRegion;
procedure SetMouseEvents;
public
{ Public-Deklarationen }
end;
var
RoundedForm: TRoundedForm;
implementation
{$R *.dfm}
procedure TRoundedForm.CreateRegion;
begin
BorderStyle := bsNone;
if FRgnHandle <> 0 then DeleteObject(FRgnHandle);
with RoundedForm.BoundsRect do
begin
FRgnHandle := CreateRoundRectRgn(0, 0, Right - Left + 1, Bottom - Top + 1,
FRgnCorner, FRgnCorner);
end;
if SetWindowRGN(Handle, FRgnHandle, True)=0 then DeleteObject(FRgnHandle);
end;
procedure TRoundedForm.DeleteRegion;
begin
if FRgnHandle <> 0 then
begin
BorderStyle := bsToolWindow;
SetWindowRGN(Handle, 0, True);
DeleteObject(FRgnHandle);
FRgnHandle := 0;
end;
end;
procedure TRoundedForm.FormCreate(Sender: TObject);
begin
SetMouseEvents;
FRgnTop := GetSystemMetrics(SM_CYCAPTION) +
GetSystemMetrics(SM_CYFRAME) +
GetSystemMetrics(SM_CYFRAME);
FRgnBottom := GetSystemMetrics(SM_CYFRAME) +
GetSystemMetrics(SM_CYFRAME);
FRgnRight := GetSystemMetrics(SM_CXFRAME) +
GetSystemMetrics(SM_CXFRAME);
FRgnLeft := GetSystemMetrics(SM_CXFRAME) +
GetSystemMetrics(SM_CXFRAME);
FRgnCorner := 15;
CreateRegion;
end;
procedure TRoundedForm.pnlMainMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (GetKeyState(VK_LBUTTON) < 0) then
begin
FMousePoint := Mouse.CursorPos;
FFormPoint := System.Classes.Point(Left, Top);
end;
end;
procedure TRoundedForm.pnlMainMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if (GetKeyState(VK_LBUTTON) < 0) then
begin
RoundedForm.left := Mouse.CursorPos.X - (FMousePoint.X - FFormPoint.X);
RoundedForm.top := Mouse.CursorPos.Y - (FMousePoint.Y - FFormPoint.Y);
end;
end;
procedure TRoundedForm.SetMouseEvents;
var i: integer;
begin
for i:=0 to self.ComponentCount-1 do
begin
if (self.Components[i] is TPanel) then
begin
TPanel(self.Components[i]).OnMouseDown:= pnlMainMouseDown;
TPanel(self.Components[i]).OnMouseMove:= pnlMainMouseMove;
end;
if (self.Components[i] is TLabel) then
begin
TLabel(self.Components[i]).OnMouseDown:= pnlMainMouseDown;
TLabel(self.Components[i]).OnMouseMove:= pnlMainMouseMove;
end;
if (self.Components[i] is TImage) then
begin
TImage(self.Components[i]).OnMouseDown:= pnlMainMouseDown;
TImage(self.Components[i]).OnMouseMove:= pnlMainMouseMove;
end;
end;
end;
procedure TRoundedForm.SpeedButton6Click(Sender: TObject);
begin
close;
end;
procedure TRoundedForm.WMMouseMove(var Msg: TWMMouseMove);
begin
if (Msg.YPos < GetSystemMetrics(SM_CYSIZEFRAME)) or
(Msg.YPos > (Height - 55)) or
(Msg.XPos < 10) or
(Msg.XPos > (Width - 25)) then
begin
DeleteRegion;
end else if (Msg.YPos >= 10) then
begin
CreateRegion;
end;
inherited;
end;
procedure TRoundedForm.WMNCButtonDown(var Msg: TWMNCLButtonDown);
begin
FNCLButtonDown := TRUE;
inherited;
end;
procedure TRoundedForm.WMNCButtonUp(var Msg: TWMNCLButtonUp);
begin
FNCLButtonDown := FALSE;
inherited;
end;
procedure TRoundedForm.WMNCMouseLeave(var Msg: TMessage);
begin
Inc(FMouseLeaveCount);
if (FRgnHandle = 0) and (not FNCLButtonDown) then
CreateRegion;
inherited;
end;
procedure TRoundedForm.WMSYSCommand(var Msg: TWMSysCommand);
begin
if Msg.CmdType = SC_RESTORE then
CreateRegion;
inherited;
end;
end.