Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Browser not getting focus ..

Post Reply
Paul_Palaszewski
Posts: 4
Joined: Wed Mar 08, 2023 1:58 pm

Browser not getting focus ..

Post by Paul_Palaszewski »

Hi,

I've an app which is very similar to the SimpleBrowser demo. Delphi 10.4 VCL, 1 fullscreen TWVBrowser, no address bar or other UI elements, just a a few setting/reload-buttons in a custom title bar. WebView4Delphi is not the latest version but definitely from 2023. Mostly works like a charm. Using it for a server side POS, so we need to process keyboard/scanner inputs. Now the strange thing: When we minimize the Window and then open it again, the browser lost focus and keyboard inputs don't reach the current document. I've checked windows + delphi forums and the 13 pages of focus releated posts+answers in this forum, but I don't find a clue.

I can catch Windows get back focus-event with

Code: Select all

  private
    SaveProc : TWndMethod;
    procedure CommonWindowProc(var Message: TMessage);
..

Code: Select all

procedure TMainForm.FormCreate(Sender: TObject);
begin
  SaveProc := WindowProc;
  WindowProc := CommonWindowProc;
end;

procedure TMainForm.CommonWindowProc(var Message: TMessage);
begin
  SaveProc(Message); // Call the original handler for the other form
  case Message.Msg of
    WM_SETFOCUS: WVBrowser1.SetFocus;
  end;
end;
But I fail to get the focus/input working again. I've seen posts suggesting to use

Code: Select all

Form.ActiveControl := WVBrowser1;
... but TWVBrowser is not a TWinControl.

Does anyone have an idea what else I could do so that keyboard input reaches the web page again?

Regards,
Paul
User avatar
salvadordf
Posts: 4079
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Browser not getting focus ..

Post by salvadordf »

Hi,

Thanks for reporting this issue!

Please, download the latest WebView4Delphi version from GitHub and try SimpleBrowser again.
Post Reply