views:

108

answers:

2

I have TWebBrowser embedded in a TForm. Whenever I press Alt button the browser window becomes white. If I drag the form around it repaints correctly.

What I am doing wrong?

I have DevExpress Bars and Quantum Grid if that matters?

I use Delphi 2010 and Windows 7 and XP SP2. IE version is 7 and 8. Reproducible on all.

Before pressing Alt:

After pressing Alt:

After pressing Alt

I have resolved it by usnig the following:

procedure TMainForm.WndProc(var Message: TMessage);
begin
  inherited WndProc(Message);
  if Message.Msg = WM_UPDATEUISTATE then
  begin
    if Assigned(ProblematicWebBrowser) then
      ProblematicWebBrowser.Repaint;
  end;
end;
A: 

FWIW, with a plain vanilla Form with a TWebBrowser in D2010, pressing Alt has not effect on the WebBrowser display.

François
Neither is it affected in D2009 under XP, IE8.
stevenvh
+3  A: 

You don't say what version of Delphi you're using, what version of Windows you're using, or what version of IE you have installed, which is what TWebBrowser wraps. (As a general note because you're a new user here, you really need to provide more information when asking a question like this. Pretend it was a user of your software reporting this bug - you'd throw your hands up and say "Bah, not reproduced. Why can't they tell me what they're doing?" Same for us when reading your question.)

But, that said, the fact it vanishes when you press the Alt key is a hint. Windows has an option to hide accelerator keys (the underline mark such as the underlined F on a File menu) until the user presses the Alt key. When it does, controls are sent a WM_DRAWITEM message indicating something's changed. See also WM_CHANGEUISTATE.

There have been bugs in past versions of Delphi handling this (see this example bug) including a bug where controls completely vanished when the Alt key was pressed. TWebBrowser isn't listed in that QC item, but it's quite possible it's affected.

So my guess is:

  • You're using Delphi 7 or earlier
  • You're using XP or above, and running themed
  • You're encountering this bug, which is affecting either the TWebBrowser control or a parent of it

Solution: upgrade Delphi or apply the fix listed in the QC item.

David M
I agree. The question is too generic. I will try to isolate the problem in a sample application. 10x for the links.
Gad D Lord
No worries, glad it helped.
David M