Solved

"Show pictures" in TWebBrowser

Posted on 2003-12-01
10
378 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month6 days, 4 hours left to enroll

626 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