Solved

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

23 Experts available now in Live!

Get 1:1 Help Now