-
Notifications
You must be signed in to change notification settings - Fork 10
/
DW.VCL.CustomForm.pas
108 lines (90 loc) · 2.5 KB
/
DW.VCL.CustomForm.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
unit DW.VCL.CustomForm;
interface
uses Classes, Forms, Controls, DW.HTML.Page, DWRenderStream, DWCallbacks,
DW.VCL.Container;
type
TDWCustomForm = class(TDWModuleContainer)
private
FHTMLPage: TDWHTMLPage;
FCaption: string;
FOnRender: TNotifyEvent;
FOnShow: TNotifyEvent;
procedure SetCaption(const Value: string);
procedure SetOnRender(const Value: TNotifyEvent);
procedure SetOnShow(const Value: TNotifyEvent);
protected
procedure DoOnRender; virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function HTMLPage: TDWHTMLPage;
procedure ExecuteCallBack(aParams: TStringList; aCallBack: TDWCallBack); virtual; abstract;
Function Render: TDWStream; virtual;
procedure Show;
published
property Caption: string read FCaption write SetCaption;
property OnRender: TNotifyEvent read FOnRender write SetOnRender;
property OnShow: TNotifyEvent read FOnShow write SetOnShow;
end;
implementation
uses
System.RTLConsts, DWUtils;
{ TDWCustomForm }
constructor TDWCustomForm.Create(AOwner: TComponent);
begin
inherited;
if (ClassType <> TDWCustomForm) and not(csDesignInstance in ComponentState) then
begin
if not InitInheritedComponent(Self, TDWCustomForm) then
raise EResNotFound.CreateFmt(SResNotFound, [ClassName]);
end
else
begin
Width := 320;
Height := 240;
end;
FHTMLPage := TDWHTMLPage.Create(Self);
// to avoid store FHTMLPage to dfm
if csDesigning in ComponentState then
RemoveComponent(FHTMLPage);
FHTMLPage.Name := 'HTMLPage';
ControlStyle := ControlStyle + [csAcceptsControls];
DoOnCreate;
end;
destructor TDWCustomForm.Destroy;
begin
inherited;
end;
function TDWCustomForm.HTMLPage: TDWHTMLPage;
begin
Result := FHTMLPage;
end;
function TDWCustomForm.Render: TDWStream;
begin
DoOnRender;
end;
procedure TDWCustomForm.SetCaption(const Value: string);
begin
FCaption := Value;
end;
procedure TDWCustomForm.SetOnRender(const Value: TNotifyEvent);
begin
FOnRender := Value;
end;
procedure TDWCustomForm.SetOnShow(const Value: TNotifyEvent);
begin
FOnShow := Value;
end;
procedure TDWCustomForm.Show;
begin
DWApplication.ActiveForm := Self;
DWApplication.AddForm(Self);
if Assigned(FOnShow) then
FOnShow(Self);
end;
procedure TDWCustomForm.DoOnRender;
begin
if Assigned(FOnRender) then
FOnRender(Self);
end;
end.