OnShowDialog


OnShowDialog is called when the webbrowser is about to display one of the standard Dialogboxes: Find, Properties, Options, Printsetup, Pagesetup etc.

You are given the handle to the Dialogbox and can make your changes to it. This is useful if you want a dialog to be opened a particular place on the screen. You can also automate the dialog, change text or cancel it.

The following code forces all dialogboxes to be opened in the upper left corner:

 

procedure TForm1.EmbeddedWB1ShowDialog(Sender: TObject; h: Cardinal);
begin
  SetWindowPos(H, 0, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOZORDER);
end;

 

You can use check the caption of the window to identify the window, as in the following code. In multi-language applications you should use other ways to identify the window. A useful way would be to identify it by size (GetwindowRect), since the standard dialogboxes have different size.

procedure TForm1.EmbeddedWB1ShowDialog(Sender: TObject; h: Cardinal);
var
I : Integer;
S : String;
begin
  I := GetWindowTextLength(H);
  SetLength(S, I + 1);
  GetWindowText(H, PChar(S), I + 1);
  If S='Find' then ......

end;