Please note that the following is undocumented. Some people say
and it works for me (on Windows 7 64-bit, with Internet Explorer 10) to check for a magical constant of the Flags
parameter. If the Flags
parameter of the OnBeforeNavigate2
event equals to 64, it was the user, who navigated through the link. If the Flags
parameter equals to 0, it was the IWebBrowser2::Navigate
method, who invoked the navigation. In code it would be:
procedure TForm1.WebBrowser1BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
if (Flags and navHyperlink) = navHyperlink then
ShowMessage('User clicked a link...')
else
ShowMessage('IWebBrowser2::Navigate has been invoked...');
end;
I wouldn't be much surprised, if that is just unintentionally undocumented flag value because that part of the MSDN is horrible.