Board index » cppbuilder » TccpWebBrowser event problem
Rolf Fankhauser
![]() CBuilder Developer |
TccpWebBrowser event problem2007-04-27 11:34:23 PM cppbuilder63 Hi, I added a form with a TccpWebBrowser to my application to show some news at start-up. I try to use the OnNavigateError to check if it is possible to load the html news page from the server. If not I want to load a page from the local app directory to inform the user that he must be online to read the news. I tried the following code: void __fastcall TFormNews::LoadPage(const WideString url, const WideString local_url) { LocalURL = local_url; CppWebBrowser1->Navigate(url); CppWebBrowser1->Refresh(); if (!FConnected) CppWebBrowser1->Navigate(LocalURL); ShowModal(); } The event handler of OnNavigateError sets the FConnect to false: void __fastcall TFormNews::CppWebBrowser1NavigateError(TObject *Sender, LPDISPATCH pDisp, Variant *URL, Variant *Frame, Variant *StatusCode, VARIANT_BOOL *Cancel) { // test if event is fired if (*Cancel) ShowMessage("Cancel = true"); else ShowMessage("Cancel = false"); FConnected = false; } Refresh() fires the OnNavigateError event but FConnect is not set to false if the program reaches the if-statement. If I include a ShowMessage("Stop!") between the Refresh() and the if-statement then all works fine! I see from the ShowMessage windows that ShowMessage("Stop!") arrives before the ShowMessage from the OnNavigateError event handler. How can I tell the program to wait until the OnNavigateError event handler has finished? Or is there another solution? First I didn't insert the Refresh(), then OnNavigateError event is fired only by ShowModal(), not by Navigate()!! Thank in advance for any help. Kind regards Rolf |