Rev 8 | Rev 27 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8 | Rev 25 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | unit WebBrowserUtils; |
1 | unit WebBrowserUtils; |
2 | 2 | ||
- | 3 | {$Include 'FastPHP.inc'} |
|
- | 4 | ||
3 | interface |
5 | interface |
4 | 6 | ||
5 | uses |
7 | uses |
6 | // In case ShDocVw_TLB can't be found, use ShDocVw |
- | |
7 | Windows, ShDocVw_TLB, SysUtils, Forms; |
8 | Windows, ShDocVw{$IFDEF USE_SHDOCVW_TLB}_TLB{$ENDIF}, SysUtils, Forms; |
8 | 9 | ||
9 | procedure WaitForBrowser(AWebBrowser: TWebbrowser); |
10 | procedure WaitForBrowser(AWebBrowser: TWebbrowser); |
10 | 11 | ||
11 | function WebBrowserLoadHTML(AWebBrowser: TWebBrowser; const AHTML: string; |
12 | function WebBrowserLoadHTML(AWebBrowser: TWebBrowser; const AHTML: string; |
12 | const AFakeURL: string=''): boolean; |
13 | const AFakeURL: string=''): boolean; |
Line 131... | Line 132... | ||
131 | AWebBrowser.Navigate('about:blank'); |
132 | AWebBrowser.Navigate('about:blank'); |
132 | WaitForBrowser(AWebBrowser); |
133 | WaitForBrowser(AWebBrowser); |
133 | end; |
134 | end; |
134 | 135 | ||
135 | pPM := AWebBrowser.Document as IPersistMoniker; |
136 | pPM := AWebBrowser.Document as IPersistMoniker; |
136 | if (pPM = nil) then Exit(false); |
137 | if (pPM = nil) then |
- | 138 | begin |
|
- | 139 | result := false; |
|
- | 140 | exit; |
|
- | 141 | end; |
|
137 | 142 | ||
138 | bindctx := nil; |
143 | bindctx := nil; |
139 | CreateBindCtx(0, bindctx); |
144 | CreateBindCtx(0, bindctx); |
140 | if (bindctx = nil) then Exit(false); |
145 | if (bindctx = nil) then |
- | 146 | begin |
|
- | 147 | result := false; |
|
- | 148 | exit; |
|
- | 149 | end; |
|
141 | 150 | ||
142 | try |
151 | try |
143 | loader := TLoadHTMLMoniker.Create; |
152 | loader := TLoadHTMLMoniker.Create; |
144 | loader.InitLoader(AHTML, url); |
153 | loader.InitLoader(AHTML, url); |
145 | except |
154 | except |
146 | Exit(false); |
155 | result := false; |
- | 156 | exit; |
|
147 | end; |
157 | end; |
148 | 158 | ||
149 | result := pPM.Load(true, loader, bindctx, STGM_READ) = S_OK; |
159 | result := pPM.Load(true, loader, bindctx, STGM_READ) = S_OK; |
150 | 160 | ||
151 | if not result and Assigned(loader) then FreeAndNil(loader); |
161 | if not result and Assigned(loader) then FreeAndNil(loader); |