Solved

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

Posted on 2011-02-19
3
547 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
[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
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

[Webinar] 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

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…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

695 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