如何讓 TWebBrowser 元件不下載圖檔 ? |
尚未結案
|
boson
中階會員 發表:74 回覆:155 積分:85 註冊:2004-07-31 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
|
boson
中階會員 發表:74 回覆:155 積分:85 註冊:2004-07-31 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
unit FzWebBrowser; interface uses Windows, Messages, SysUtils, Classes, Graphics,Controls, OleCtrls, SHDocVw_TLB, MSHTML_TLB,ActiveX, shlObj, Wininet, Urlmon,shellapi; const DISPID_AMBIENT_DLCONTROL = (-5512); type TDownloadControlOption = ( DLCTL_DLIMAGES, DLCTL_VIDEOS, DLCTL_BGSOUNDS, DLCTL_NO_SCRIPTS, //$00000010, $00000020, $00000040, $00000080, DLCTL_NO_JAVA, DLCTL_NO_RUNACTIVEXCTLS, DLCTL_NO_DLACTIVEXCTLS, DLCTL_DOWNLOADONLY, //$00000100, $00000200, $00000400, $00000800, DLCTL_NO_FRAMEDOWNLOAD, DLCTL_RESYNCHRONIZE, DLCTL_PRAGMA_NO_CACHE, DLCTL_NO_BEHAVIORS, //$00001000, $00002000, $00004000, $00008000, DLCTL_NO_METACHARSET, DLCTL_URL_ENCODING_DISABLE_UTF8, DLCTL_URL_ENCODING_ENABLE_UTF8,DLCTL_OFFLINEIFNOTCONNECTED, //$00010000, $00020000, $00040000, $00080000, DLCTL_FORCEOFFLINE, DLCTL_NO_CLIENTPULL, DLCTL_SILENT, DLCTL_OFFLINE //$10000000, $20000000, $40000000, $80000000 ); const acardDownloadControlValues: array[TDownloadControlOption] of Cardinal = ($00000010, $00000020, $00000040, $00000080, $00000100, $00000200, $00000400, $00000800, $00001000, $00002000, $00004000, $00008000, $00010000, $00020000, $00040000, $00080000, $10000000, $20000000, $40000000, $80000000); type TDownloadControlOptions = set of TDownloadControlOption; TFzWebBrowser = class(TWebBrowser,IDispatch) private { Private declarations } FDownloadOptionValue: Longint; FDownloadControlOptions: TDownloadControlOptions; procedure SetDownloadOptions(const Value: TDownloadControlOptions); procedure UpdateDownloadControlValue; protected { Protected declarations } function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer; Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall; public { Public declarations } property DownloadOptionValue:Longint read FDownloadOptionValue write FDownloadOptionValue; published { Published declarations } property DownloadOptions: TDownloadControlOptions read FDownloadControlOptions write SetDownloadOptions; end; procedure Register; implementation function TFzWebBrowser.Invoke(DispID: Integer; const IID: TGUID; LocaleID:Integer; Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall; begin Result := S_OK; if (Flags and DISPATCH_PROPERTYGET <> 0) and (VarResult <> nil) and (DispId = DISPID_AMBIENT_DLCONTROL) then PVariant(VarResult)^ := FDownloadOptionValue else Result := inherited Invoke(DispID, IID, LocaleID, Flags, Params, VarResult, ExcepInfo, ArgErr); end; procedure TFzWebBrowser.SetDownloadOptions(const Value: TDownloadControlOptions); begin FDownloadControlOptions := Value; UpdateDownloadControlValue; (Application as IOleControl).OnAmbientPropertyChange(DISPID_AMBIENT_DLCONTROL); end; procedure TFzWebBrowser.UpdateDownloadControlValue; var i: TDownloadControlOption; begin FDownloadOptionValue := 0; if (FDownloadControlOptions <> []) then for i := Low(TDownloadControlOption) to High(TDownloadControlOption)do if (i in FDownloadControlOptions) then Inc(FDownloadOptionValue, acardDownloadControlValues[i]); end; procedure Register; begin RegisterComponents('ActiveX', [TFzWebBrowser]); end; end.網海無涯,唯學是岸! 因為擁有,所以分享! |
boson
中階會員 發表:74 回覆:155 積分:85 註冊:2004-07-31 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |