Detect Error 404 with TWebBrowser

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Detect Error 404 with TWebBrowser

Postby macicogna » Sun Jun 28, 2015 3:13 pm

Hi All,

Does someone know how to detect an invalid URL or, as result, an "Error 404" when using a TWebBrowser object?

Thanks,

Marcelo.
User avatar
macicogna
BCBJ Veteran
BCBJ Veteran
 
Posts: 64
Joined: Mon Aug 04, 2008 4:57 pm
Location: Brazil

Re: Detect Error 404 with TWebBrowser

Postby rlebeau » Mon Jun 29, 2015 7:15 pm

The TWebBrowser::OnNavigateError event has a StatusCode parameter.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1498
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: Detect Error 404 with TWebBrowser

Postby macicogna » Tue Jun 30, 2015 5:23 am

Hi Remy,

It's working.

Code: Select all
void __fastcall
TAppAnalytics::BrowserNavigateError(System::TObject* ASender,
  const _di_IDispatch pDisp, const System::OleVariant &URL,
  const System::OleVariant &Frame, const System::OleVariant &StatusCode,
  System::WordBool &Cancel)
{
  if (FMemoLog)
  {
    FMemoLog->Lines->Add( "TWebBrowser object error: navigate error." );
    FMemoLog->Lines->Add( "  Status Code: " + IntToStr(int(StatusCode)) );
  }
}


Thanks again,

Marcelo.
User avatar
macicogna
BCBJ Veteran
BCBJ Veteran
 
Posts: 64
Joined: Mon Aug 04, 2008 4:57 pm
Location: Brazil


Return to Technical

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 19 guests

cron