-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathYOTM.Form.Dialog.pas
86 lines (71 loc) · 2.08 KB
/
YOTM.Form.Dialog.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
unit YOTM.Form.Dialog;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
YOTM.Form.ModalEdit, Vcl.ExtCtrls, HGM.Button, Vcl.StdCtrls,
HGM.Controls.PanelExt;
type
TFormAnswer = class(TFormModalEdit)
LabelQuestion: TLabel;
private
{ Private declarations }
public
class function GetAnswer(Question: string; NearMouse: Boolean = False): Boolean;
class function ShowNeedAction(NeedAction: string; NearMouse: Boolean = False): Boolean;
end;
var
FormAnswer: TFormAnswer;
function GetAnswer(Question: string; NearMouse: Boolean = False): Boolean;
function ShowNeedAction(NeedAction: string; NearMouse: Boolean = False): Boolean;
implementation
{$R *.dfm}
function GetAnswer(Question: string; NearMouse: Boolean = False): Boolean;
begin
Result := TFormAnswer.GetAnswer(Question, NearMouse);
end;
function ShowNeedAction(NeedAction: string; NearMouse: Boolean = False): Boolean;
begin
Result := TFormAnswer.ShowNeedAction(NeedAction, NearMouse);
end;
{ TFormAnswer }
class function TFormAnswer.GetAnswer(Question: string; NearMouse: Boolean = False): Boolean;
begin
with TFormAnswer.Create(nil) do
begin
Caption := 'Âîïðîñ';
LabelQuestion.Caption := Question;
if NearMouse then
begin
Position := poDesigned;
Left := Mouse.CursorPos.X - Width div 2;
Top := Mouse.CursorPos.Y - Height div 2;
end
else
Position := poMainFormCenter;
Result := ShowModal = mrOk;
Free;
end;
end;
class function TFormAnswer.ShowNeedAction(NeedAction: string; NearMouse: Boolean = False): Boolean;
begin
with TFormAnswer.Create(nil) do
begin
Caption := 'Âíèìàíèå';
LabelQuestion.Caption := NeedAction;
ButtonFlatOK.Caption := 'Îê';
ButtonFlatCancel.Hide;
if NearMouse then
begin
Position := poDesigned;
Left := Mouse.CursorPos.X - Width div 2;
Top := Mouse.CursorPos.Y - Height div 2;
end
else
Position := poMainFormCenter;
ShowModal;
Result := True;
Free;
end;
end;
end.