title: Intercept hyperlink click with Delphi TWebBrowser
body: <p>Using Delphi 7, with a TWebBrowser component with a HTML file loaded... How does one intercept a hyperlink click so that I can decide whether to do something other than allow the TWebBrowser to fetch the link?</p>
  
  <p>I have tried the following, but the event is never triggered when I click on a hyperlink:</p>
  
  <pre><code>procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
    const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
    Headers: OleVariant; var Cancel: WordBool);
  begin
    Cancel := True;
    ShowMessage(URL);
    WebBrowser1.Stop;
  end;
  </code></pre>