1 //////////////////////////////////////////////////////////////////////////////////
4 // TKOLWebBrowser v1.0 //
6 // Author: Dimaxx (dimaxx@atnet.ru) //
9 //////////////////////////////////////////////////////////////////////////////////
15 uses Classes
, Kol
, Mirror
;
18 TWebBrowserStatusTextChange
= procedure(Sender
: TObject
; const Text: WideString
) of object;
19 TWebBrowserProgressChange
= procedure(Sender
: TObject
; Progress
: Integer; ProgressMax
: Integer) of object;
20 TWebBrowserCommandStateChange
= procedure(Sender
: TObject
; Command
: Integer; Enable
: WordBool
) of object;
21 TWebBrowserTitleChange
= procedure(Sender
: TObject
; const Text: WideString
) of object;
22 TWebBrowserPropertyChange
= procedure(Sender
: TObject
; const szProperty
: WideString
) of object;
23 TWebBrowserBeforeNavigate2
= procedure(Sender
: TObject
; const pDisp
: IDispatch
;
25 var Flags
: OleVariant
;
26 var TargetFrameName
: OleVariant
;
27 var PostData
: OleVariant
;
28 var Headers
: OleVariant
;
29 var Cancel
: WordBool
) of object;
30 TWebBrowserNewWindow2
= procedure(Sender
: TObject
; var ppDisp
: IDispatch
; var Cancel
: WordBool
) of object;
31 TWebBrowserNavigateComplete2
= procedure(Sender
: TObject
; const pDisp
: IDispatch
;
32 var URL
: OleVariant
) of object;
33 TWebBrowserDocumentComplete
= procedure(Sender
: TObject
; const pDisp
: IDispatch
;
34 var URL
: OleVariant
) of object;
35 TWebBrowserOnVisible
= procedure(Sender
: TObject
; Visible
: WordBool
) of object;
36 TWebBrowserOnToolBar
= procedure(Sender
: TObject
; ToolBar
: WordBool
) of object;
37 TWebBrowserOnMenuBar
= procedure(Sender
: TObject
; MenuBar
: WordBool
) of object;
38 TWebBrowserOnStatusBar
= procedure(Sender
: TObject
; StatusBar
: WordBool
) of object;
39 TWebBrowserOnFullScreen
= procedure(Sender
: TObject
; FullScreen
: WordBool
) of object;
40 TWebBrowserOnTheaterMode
= procedure(Sender
: TObject
; TheaterMode
: WordBool
) of object;
42 TKOLWebBrowser
= class(TKOLCustomControl
)
44 FOnStatusTextChange
: TWebBrowserStatusTextChange
;
45 FOnProgressChange
: TWebBrowserProgressChange
;
46 FOnCommandStateChange
: TWebBrowserCommandStateChange
;
47 FOnTitleChange
: TWebBrowserTitleChange
;
48 FOnPropertyChange
: TWebBrowserPropertyChange
;
49 FOnBeforeNavigate2
: TWebBrowserBeforeNavigate2
;
50 FOnNewWindow2
: TWebBrowserNewWindow2
;
51 FOnNavigateComplete2
: TWebBrowserNavigateComplete2
;
52 FOnDocumentComplete
: TWebBrowserDocumentComplete
;
53 FOnVisible
: TWebBrowserOnVisible
;
54 FOnToolBar
: TWebBrowserOnToolBar
;
55 FOnMenuBar
: TWebBrowserOnMenuBar
;
56 FOnStatusBar
: TWebBrowserOnStatusBar
;
57 FOnFullScreen
: TWebBrowserOnFullScreen
;
58 FOnTheaterMode
: TWebBrowserOnTheaterMode
;
62 FRegisterAsBrowser
: boolean;
63 FRegisterAsDropTarget
: boolean;
65 function AdditionalUnits
: string; override;
66 procedure SetupFirst(SL
: TStringList
; const AName
,AParent
,Prefix
: string); override;
67 procedure AssignEvents(SL
: TStringList
; const AName
: string); override;
68 procedure SetOnStatusTextChange(E
: TWebBrowserStatusTextChange
);
69 procedure SetOnProgressChange(E
: TWebBrowserProgressChange
);
70 procedure SetOnCommandStateChange(E
: TWebBrowserCommandStateChange
);
71 procedure SetOnTitleChange(E
: TWebBrowserTitleChange
);
72 procedure SetOnPropertyChange(E
: TWebBrowserPropertyChange
);
73 procedure SetOnBeforeNavigate2(E
: TWebBrowserBeforeNavigate2
);
74 procedure SetOnNewWindow2(E
: TWebBrowserNewWindow2
);
75 procedure SetOnNavigateComplete2(E
: TWebBrowserNavigateComplete2
);
76 procedure SetOnDocumentComplete(E
: TWebBrowserDocumentComplete
);
77 procedure SetOnVisible(E
: TWebBrowserOnVisible
);
78 procedure SetOnToolBar(E
: TWebBrowserOnToolBar
);
79 procedure SetOnMenuBar(E
: TWebBrowserOnMenuBar
);
80 procedure SetOnStatusBar(E
: TWebBrowserOnStatusBar
);
81 procedure SetOnFullScreen(E
: TWebBrowserOnFullScreen
);
82 procedure SetOnTheaterMode(E
: TWebBrowserOnTheaterMode
);
84 procedure SetOffline(V
: boolean);
85 procedure SetSilent(V
: boolean);
86 procedure SetRegisterAsBrowser(V
: boolean);
87 procedure SetRegisterAsDropTarget(V
: boolean);
89 constructor Create(AOwner
: TComponent
); override;
98 property Offline
: boolean read FOffline write SetOffline default
True;
99 property Silent
: boolean read FSilent write SetSilent default
False;
100 property RegisterAsBrowser
: boolean read FRegisterAsBrowser write SetRegisterAsBrowser default
True;
101 property RegisterAsDropTarget
: boolean read FRegisterAsDropTarget write SetRegisterAsDropTarget default
False;
103 property OnStatusTextChange
: TWebBrowserStatusTextChange read FOnStatusTextChange write SetOnStatusTextChange
;
104 property OnProgressChange
: TWebBrowserProgressChange read FOnProgressChange write SetOnProgressChange
;
105 property OnCommandStateChange
: TWebBrowserCommandStateChange read FOnCommandStateChange write SetOnCommandStateChange
;
106 property OnTitleChange
: TWebBrowserTitleChange read FOnTitleChange write SetOnTitleChange
;
107 property OnPropertyChange
: TWebBrowserPropertyChange read FOnPropertyChange write SetOnPropertyChange
;
108 property OnBeforeNavigate2
: TWebBrowserBeforeNavigate2 read FOnBeforeNavigate2 write SetOnBeforeNavigate2
;
109 property OnNewWindow2
: TWebBrowserNewWindow2 read FOnNewWindow2 write SetOnNewWindow2
;
110 property OnNavigateComplete2
: TWebBrowserNavigateComplete2 read FOnNavigateComplete2 write SetOnNavigateComplete2
;
111 property OnDocumentComplete
: TWebBrowserDocumentComplete read FOnDocumentComplete write SetOnDocumentComplete
;
112 property OnVisible
: TWebBrowserOnVisible read FOnVisible write SetOnVisible
;
113 property OnToolBar
: TWebBrowserOnToolBar read FOnToolBar write SetOnToolBar
;
114 property OnMenuBar
: TWebBrowserOnMenuBar read FOnMenuBar write SetOnMenuBar
;
115 property OnStatusBar
: TWebBrowserOnStatusBar read FOnStatusBar write SetOnStatusBar
;
116 property OnFullScreen
: TWebBrowserOnFullScreen read FOnFullScreen write SetOnFullScreen
;
117 property OnTheaterMode
: TWebBrowserOnTheaterMode read FOnTheaterMode write SetOnTheaterMode
;
127 AlignValues
: array[TKOLAlign
] of string = ('caNone','caLeft','caTop','caRight','caBottom','caClient');
128 Bool2Str
: array [Boolean] of string = ('False','True');
132 RegisterComponents('KOL',[TKOLWebBrowser
]);
135 constructor TKOLWebBrowser
.Create
;
140 FRegisterAsBrowser
:=True;
141 FRegisterAsDropTarget
:=False;
144 function TKOLWebBrowser
.AdditionalUnits
;
146 Result
:=', KOLWebBrowser';
149 procedure TKOLWebBrowser
.SetupFirst
;
151 SL
.Add(Prefix
+AName
+' := NewKOLWebBrowser(Result.Form); ');
152 if Align
<>caNone
then
154 SL
.Add(Prefix
+AName
+'.SetAlign( '+AlignValues
[Align
]+'); ');
158 SL
.Add(Prefix
+AName
+'.SetPosition(' +int2str(Left
)+', '+int2str(Top
)+' );');
159 SL
.Add(Prefix
+AName
+'.SetSize(' +int2str(Width
)+', '+int2str(Height
)+' );');
161 SL
.Add(Prefix
+AName
+'.Offline := '+Bool2Str
[FOffline
]+';');
162 SL
.Add(Prefix
+AName
+'.Silent := '+Bool2Str
[FSilent
]+';');
163 SL
.Add(Prefix
+AName
+'.RegisterAsBrowser := '+Bool2Str
[FRegisterAsBrowser
]+';');
164 SL
.Add(Prefix
+AName
+'.RegisterAsDropTarget := '+Bool2Str
[FRegisterAsDropTarget
]+';');
165 AssignEvents(SL
,AName
);
168 procedure TKOLWebBrowser
.AssignEvents
;
171 DoAssignEvents(SL
,AName
,
172 ['OnStatusTextChange','OnProgressChange','OnCommandStateChange',
173 'OnTitleChange','OnPropertyChange','OnBeforeNavigate2','OnNewWindow2',
174 'OnNavigateComplete2','OnDocumentComplete','OnVisible','OnToolBar',
175 'OnMenuBar','OnStatusBar','OnFullScreen','OnTheaterMode'],
176 [@OnStatusTextChange
,@OnProgressChange
,@OnCommandStateChange
,
177 @OnTitleChange
,@OnPropertyChange
,@OnBeforeNavigate2
,@OnNewWindow2
,
178 @OnNavigateComplete2
,@OnDocumentComplete
,@OnVisible
,@OnToolBar
,
179 @OnMenuBar
,@OnStatusBar
,@OnFullScreen
,@OnTheaterMode
]);
182 procedure TKOLWebBrowser
.SetOffline
;
188 procedure TKOLWebBrowser
.SetSilent
;
194 procedure TKOLWebBrowser
.SetRegisterAsBrowser
;
196 FRegisterAsBrowser
:=V
;
200 procedure TKOLWebBrowser
.SetRegisterAsDropTarget
;
202 FRegisterAsDropTarget
:=V
;
206 procedure TKOLWebBrowser
.SetOnStatusTextChange
;
208 FOnStatusTextChange
:=E
;
212 procedure TKOLWebBrowser
.SetOnProgressChange
;
214 FOnProgressChange
:=E
;
218 procedure TKOLWebBrowser
.SetOnCommandStateChange
;
220 FOnCommandStateChange
:=E
;
224 procedure TKOLWebBrowser
.SetOnTitleChange
;
230 procedure TKOLWebBrowser
.SetOnPropertyChange
;
232 FOnPropertyChange
:=E
;
236 procedure TKOLWebBrowser
.SetOnBeforeNavigate2
;
238 FOnBeforeNavigate2
:=E
;
242 procedure TKOLWebBrowser
.SetOnNewWindow2
;
248 procedure TKOLWebBrowser
.SetOnNavigateComplete2
;
250 FOnNavigateComplete2
:=E
;
254 procedure TKOLWebBrowser
.SetOnDocumentComplete
;
256 FOnDocumentComplete
:=E
;
260 procedure TKOLWebBrowser
.SetOnVisible
;
266 procedure TKOLWebBrowser
.SetOnToolBar
;
272 procedure TKOLWebBrowser
.SetOnMenuBar
;
278 procedure TKOLWebBrowser
.SetOnStatusBar
;
284 procedure TKOLWebBrowser
.SetOnFullScreen
;
290 procedure TKOLWebBrowser
.SetOnTheaterMode
;