• R/O
  • SSH
  • HTTPS

akdf: Commit


Commit MetaInfo

Revision344 (tree)
Time2019-02-04 22:47:35
Authorderekwildstar

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/KRKLIB/SRC/Vcl/KRK.Lib.Vcl.Forms.FormBlender.pas (nonexistent)
+++ trunk/KRKLIB/SRC/Vcl/KRK.Lib.Vcl.Forms.FormBlender.pas (revision 344)
@@ -0,0 +1,108 @@
1+unit KRK.Lib.Vcl.Forms.FormBlender;
2+
3+interface
4+
5+uses
6+ Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
7+ Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
8+
9+type
10+ TKRKFormBlender = class(TForm)
11+ TIME: TTimer;
12+ procedure FormCreate(Sender: TObject);
13+ procedure TIMETimer(Sender: TObject);
14+ procedure FormShow(Sender: TObject);
15+ private
16+ { Private declarations }
17+ FInternalForm: TFormClass;
18+ FInternalFormInstance: TForm;
19+ FModal: Boolean;
20+ function GetInternalFormVisible: Boolean;
21+ public
22+ { Public declarations }
23+ class function ShowMe(AOwner: TForm; AInternalForm: TFormClass): TModalResult; overload;
24+ class procedure ShowMe(AOwner: TForm; AInternalForm: TFormClass; out AFormBlender: TKRKFormBlender); overload;
25+
26+ property InternalFormVisible: Boolean read GetInternalFormVisible;
27+ property InternalFormInstance: TForm read FInternalFormInstance;
28+ end;
29+
30+implementation
31+
32+{$R *.dfm}
33+
34+procedure TKRKFormBlender.FormCreate(Sender: TObject);
35+begin
36+ Top := TForm(Owner).Top;
37+ Left := TForm(Owner).Left;
38+ Height := TForm(Owner).Height;
39+ Width := TForm(Owner).Width;
40+end;
41+
42+procedure TKRKFormBlender.FormShow(Sender: TObject);
43+begin
44+ TIME.Enabled := True;
45+end;
46+
47+function TKRKFormBlender.GetInternalFormVisible: Boolean;
48+begin
49+ Result := Assigned(FInternalFormInstance) and FInternalFormInstance.Visible
50+end;
51+
52+class procedure TKRKFormBlender.ShowMe(AOwner: TForm; AInternalForm: TFormClass; out AFormBlender: TKRKFormBlender);
53+begin
54+ AFormBlender := Self.Create(AOwner);
55+ with AFormBlender do
56+ begin
57+ FInternalForm := AInternalForm;
58+ FModal := False;
59+ Show;
60+ Application.ProcessMessages;
61+ end;
62+end;
63+
64+class function TKRKFormBlender.ShowMe(AOwner: TForm; AInternalForm: TFormClass): TModalResult;
65+begin
66+ with Self.Create(AOwner) do
67+ try
68+ FInternalForm := AInternalForm;
69+ FModal := True;
70+ Result := ShowModal;
71+ finally
72+ Close;
73+ Free;
74+ end;
75+end;
76+
77+procedure TKRKFormBlender.TIMETimer(Sender: TObject);
78+begin
79+ TIME.Enabled := False;
80+ if Assigned(FInternalForm) then
81+ begin
82+ FInternalFormInstance := FInternalForm.Create(Self);
83+ with FInternalFormInstance do
84+ if FModal then
85+ try
86+ BorderStyle := bsNone;
87+
88+ Top := Self.Top + Self.Height div 2 - Height div 2;
89+ Left := Self.Left + Self.Width div 2 - Width div 2;
90+
91+ Self.ModalResult := ShowModal;
92+ finally
93+ Close;
94+ Free;
95+ end
96+ else
97+ begin
98+ BorderStyle := bsNone;
99+
100+ Top := Self.Top + Self.Height div 2 - Height div 2;
101+ Left := Self.Left + Self.Width div 2 - Width div 2;
102+
103+ Show;
104+ end;
105+ end;
106+end;
107+
108+end.
Show on old repository browser