Solved

"Show pictures" in TWebBrowser

Posted on 2003-12-01
10
370 Views
Last Modified: 2010-04-03
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
Comment
Question by:Slavak
10 Comments
 
LVL 1

Accepted Solution

by:
roknjohn earned 84 total points
ID: 9852376
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
 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 83 total points
ID: 9853102
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
 
LVL 1

Expert Comment

by:roknjohn
ID: 9853431
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 26

Expert Comment

by:EddieShipman
ID: 9853698
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
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9853708
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
 
LVL 3

Author Comment

by:Slavak
ID: 9857459
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
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9858245
I think you can intercept the response stream before it gets loaded into the WebBorwser. Let me take a look
at it.
0
 
LVL 3

Assisted Solution

by:Peter_
Peter_ earned 83 total points
ID: 9858846
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question