Solved

In Delphi - I need to have a ListBox record the destination URL of the images I click

Posted on 2011-02-19
3
540 Views
Last Modified: 2012-05-11
Thanks for reading

this image depicts the program I need to build:

http://img252.imageshack.us/img252/5069/clickclick.gif

A typical "website photo gallery" will contain thumbnail images which contain an HREF tag which points to the BIGGER version of that picture.

I need to be able to click on this thumbnail image, and have the URL appear in a listbox.

I would like the WebBrowser component to function in no other way. e.g. i don't want it to actually go to the bigger image when I click. I just need the destination URL.

Got any ideas?

Thanks!
0
Comment
Question by:bobbysdog
3 Comments
 
LVL 3

Expert Comment

by:maosalah
ID: 34935629
0
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 34935630
Having Button, WebBrowser and ListBox on the form add the following code:
The code of the WebBrowser is at "OnBeforeNavigate2" and "OnDocumentComplete":
var  //Global variable
  NavigateCompleted:Boolean=False;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Webbrowser1.Navigate('YourMainURL');
end;

procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
  const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);
begin
  if NavigateCompleted then
    begin
      ListBox1.Items.Add(URL);
      Cancel := true;
    end;
end;

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  NavigateCompleted := true;  // set it to false to be able to navigate other URLs
end;

Open in new window

Please note: to be able to navigate to other URLs you need to set the variable "NavigateCompleted" to False.
0
 

Author Closing Comment

by:bobbysdog
ID: 34935699
wow thanks this is awesome!!!!!!!!!
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
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 …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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