Solved

"Show pictures" in TWebBrowser

Posted on 2003-12-01
10
372 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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