Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

WEBBROWSER

Posted on 2004-05-12
8
Medium Priority
?
548 Views
Last Modified: 2012-06-27
Hi, I have a question about WebBrowser component on Delphi 5. is it possible to get WebSite Icon using WebBrowser component? Thank you
0
Comment
Question by:pedro8
  • 3
5 Comments
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 172 total points
ID: 11050524

  the icon is in the HTML document, so you can search for it...

   <link href="http://i.dirbg.com/dir.ico" rel="SHORTCUT ICON">
0
 
LVL 11

Assisted Solution

by:shaneholmes
shaneholmes earned 164 total points
ID: 11050896

Check out the excepted anser to this post:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20793583.html?query=html+Element&searchType=topic

Modify it to parse for SHORTCUT ICON

Shane
0
 
LVL 26

Assisted Solution

by:Eddie Shipman
Eddie Shipman earned 164 total points
ID: 11053973
Try this option...

function GetFavIcon(Doc:IHTMLDocument2):String;
var
  All: IHtmlElementCollection;
  E: IhtmlElement;
  Element: TElementInfo;
  x: INteger;
  ELink: IHTMLLinkElement;
  DocLoc: String;
begin
  DocLoc := Doc.location.toString;
  DocLoc := Copy(DocLoc, 1, Length(DocLoc)-1);
  All := Doc.Get_all;
  if (All <> nil) then
  begin
    for x := 0 to All.length - 1 do
    begin
      E := All.item(x, 0) as IHTMLElement;
      if E.tagName = 'LINK' then
      begin
        ELink := E as IHTMLLinkElement;
        if ( Pos('SHORTCUT', UpperCase(ELink.rel)) > 0 ) or
           ( Pos('ICON', UpperCase(ELink.rel)) > 0 )     then
          Result := DocLoc + ELink.href;
      end;
    end;
  end;
end;

procedure TForm1.WebBrowser1NavigateComplete2(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  Label1.Caption := GetFavIcon(WebBrowser1.Document as IHTMLDocument2);
end;

However, since IE caches the FavIcon based upon the domain, not all pages
may have this particular link tag. I don't know about Mozilla, Netscape, etc...
0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 11053981
add mshtml to your uses for D6+ or import MSHTML type library.
0
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 12135362
So, Pedro8, why have you not accepted the answer, yet?
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

577 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