Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

"Show pictures" in TWebBrowser

Does someone can provide me an example code how tell to TWebBrowser to download only requested page and not all images/links etc.?

In explorer it "Show pictures" checbox in advanced options tab, but how to control it for single TWebBrowser component?
0
Slavak
Asked:
Slavak
3 Solutions
 
roknjohnCommented:
I'm not sure how to do it with a TWebBrowser off the top of my head.  But if you just need the single HTML file without loading everything, why not use a idHTTP or similar component to fetch the file?

See http://www.indyproject.org/  for details on the Indy freeware components

var
    HTTP: TIdHTTP;
    MyPage : String;
begin
  HTTP := TIdHTTP.Create(nil);
  MyPage := HTTP.Get('http://jcent.com/index.htm');
  HTTP.Free;
end;
0
 
EddieShipmanCommented:
You need to change it in the registry because it uses the settings for the version of IE that is installed.

Key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
Value: "Display Inline Images"="no"
0
 
roknjohnCommented:
I'm thinking Slavak just wants to disable the images for this instance and not for other IE tasks.  Wouldn't changing the registry settings effect IE system-wide and not just for his program?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
EddieShipmanCommented:
Well, yes, but that is the ONLY way to do it.

He must change them upon using TWebBrowser and change
them back if he wants to do it this way and keep the default
settings.
0
 
EddieShipmanCommented:
He could also use idhttp to download the source, replce all the img tags with a img tag that directed
to a placeholder and then load the html into the webbrowser. But that would negate any navigation
via the webbrowser.

I just don't see how it's going to be done without affecting all browser instances.
0
 
SlavakAuthor Commented:
thanks, guys.

I will try to be more specific:

I want to download html document from server.

There are some reasons why I want to do it with TWebBrowser and not with Indy, ICS or any other available http component. Most important of them is:

1) I don't want to fight again any firewall/proxy issues.
2) the page I want to download is on secure site - means:

a) component must support https protocol
b) before downloading requested page I must go through logon page and post username/password information. TWebBrowser (like explorer) save existing session, so I can logon only once and download any number of pages even create number of TWebBrowser components that can download number of pages at same time without requesting additional logon.

If you know another way (component) to do that please tell me.

The problem I have with TWebBrowser is only performance because it download unrequested files from server: images, frames etc.

I found code in c++ that override Invoke function for DISPID_AMBIENT_DLCONTROL that can be useful, but cannot do the same in delphi :(.





0
 
EddieShipmanCommented:
I think you can intercept the response stream before it gets loaded into the WebBorwser. Let me take a look
at it.
0
 
Peter_Commented:
To stop frames from downloading, I think you can use:

void BeforeNavigate2(          IDispatch *pDisp,
    VARIANT *&url,
    VARIANT *&Flags,
    VARIANT *&TargetFrameName,
    VARIANT *&PostData,
    VARIANT *&Headers,
    VARIANT_BOOL *&Cancel
);

Since this event fires once for the main document and then once for each frame. Try check if (pDisp=Webbrowser1.DefaultInterface), if not then this is a frame and not the main document. In that case set Cancel:=True.

To block large images, maybe you could try calling stop when the

void NavigateComplete2(          IDispatch *pDisp,
    VARIANT *URL
);

Is called? Since this might happen before all images have loaded.

Just some ideas :).
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now