1

I wrote a software and added it to windows startup. When app starts, it navigates a webpage. However, TWebbrowser freezes GUI until it is prepared to run. During this time, i can not do anything because gui is frozen. Does anyone have any solution to this?

I know it is just Internet Explorer ActiveX and IE also freezing if i add it to startup. This doesn't happen if i run it second time. Only happens on Windows startup.

I have XE5 here and my IE is 11. But in my office i have tested it in IE8 and IE9.

procedure TfrmUsers.CallWeb(szUrl: string);
var
  Flags: OLEVariant;
begin
  try
    Flags := navNoHistory or navNoReadFromCache or navNoWriteToCache;
    WebBrowser1.Navigate(szUrl, Flags);
  except
  end;
end;

procedure TfrmUsers.FormShow(Sender: TObject);
begin
  CallWeb(APP_WEB);
end;

-K

Kara
  • 6,115
  • 16
  • 50
  • 57
blacksun
  • 733
  • 7
  • 24
  • I've experienced the same after upgrading to IE 11. The application I've been maintaining that time had a waiting loop for `ReadyState` value `READYSTATE_COMPLETE` which gets never reached and that led to an endless loop calling `Application.ProcessMessages`. – TLama Jan 12 '14 at 14:13
  • Actually I just do Webbrowser.Navigate('www.example.com') without checking readystate. Do i need to wait for it? – blacksun Jan 12 '14 at 14:15
  • No. You're probably having a different problem. It was just a first guess based on my experience. Without seeing a real code during initialization we can only guess... – TLama Jan 12 '14 at 14:17
  • It is unclear what you are asking – David Heffernan Jan 12 '14 at 14:18
  • @DavidHeffernan why do you say that? TWebBrowser freezes UI until it loads the page. Actually, it freezes UI until it start trying to load the page. – blacksun Jan 12 '14 at 14:20
  • Do you navigate to `about:blank` at start up? you should try that. also make sure you navigate when the Host form has handle allocated (e.g. Form.OnShow). – kobik Jan 12 '14 at 14:25
  • 2
    It is unclear what you are asking. Present an SSCCE. – David Heffernan Jan 12 '14 at 14:26
  • @kobik yes. I do that before i call the website. – blacksun Jan 12 '14 at 14:27
  • Do you use a ReadyState/ProcessMessages loop? have you tried to utilize document on load event instead? Show us some code please. – kobik Jan 12 '14 at 14:28
  • No i don't do that ReadyState/ProcessMessages. Do i think i need to? What do you mean by "utilize document on load event"? – blacksun Jan 12 '14 at 14:29
  • 1
    I can't give you a direction until we see the REAL code. – kobik Jan 12 '14 at 14:31
  • @blacksun: while your question is clear, it may be useful to add a small example so we can reproduce the problem? – whosrdaddy Jan 12 '14 at 15:07
  • I have edited the question so please find the real code – blacksun Jan 12 '14 at 15:07
  • 1
    Does it freeze with IE8/9 also? I don't have much time to reproduce right now (the start-up issue). but from my experience with TWebBrowser the host window should be allocated and visible! I also learned to expect the unexpected (with every version update) :))) try to move your code to `FormActivate`. do you even have a visible UI or do you use the TWebBrowser for other things? Also, Try to debug the ready state (like the comment TLama added) - which is it? have you tried 'about:blank'? does it also freezes? – kobik Jan 12 '14 at 15:28
  • why not start it during form creation perhaps a splash screen. Doesn't solve the real problem but as the problem only occurs with initial startup that maybe an option. – Merlin W. Jan 12 '14 at 16:59
  • Actually it freezes as soon as i call Navigate(). That is the problem. I have tried that before. I have added a button and called Navigate() on click event. This only happens during windows startup. I need to check the IE version tomorrow when i am back at office. – blacksun Jan 12 '14 at 17:05
  • Do you think it may be useful to wait READYSTATE_COMPLETE before i call Navigate() ? – blacksun Jan 12 '14 at 17:53
  • I am checking ReadyState before i call Navigate() and it seems that ReadyState is READYSTATE_COMPLETE before i call Navigate(). After i call Navigate() it takes about 5-10 seconds to step next line. So it doesn't seem multi-threaded and freezes the GUI – blacksun Jan 13 '14 at 10:03

0 Answers0