Solved

"Show pictures" in TWebBrowser

Posted on 2003-12-01
10
367 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now