Thanks Xander, you're a miracle worker!!!

Cheers,
David O'Brien.

-----Original Message-----
From: Xander van der Merwe [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 29 April 1999 21:22
To: Multiple recipients of list delphi
Subject: Re: [DUG]: WebBrowser Component


Dave, the following code snippet should do what you want:

//----------------------------------------------------------------------
----
--------
..

var
  Form1: TForm1;
  FOleInPlaceActiveObject: IOleInPlaceActiveObject;
  SaveMessageHandler: TMessageEvent;

...

implementation
...

procedure TForm1.FormActivate(Sender: TObject);
begin
  SaveMessageHandler := Application.OnMessage;
  Application.OnMessage := MyMessageHandler;
end;

procedure TForm1.FormDeactivate(Sender: TObject);
begin
  Application.OnMessage := SaveMessageHandler;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Application.OnMessage := SaveMessageHandler;
  FOleInPlaceActiveObject := nil;
end;

procedure TForm1.MyMessageHandler(var Msg: TMsg; var Handled: Boolean);
var
  iOIPAO: IOleInPlaceActiveObject;
  Dispatch: IDispatch;
begin
  { exit if we don't get back a webbrowser object }
  if WebBrowser = nil then
  begin
    Handled := False;
    Exit;
  end;

  Handled:=(IsDialogMessage(WebBrowser.Handle, Msg) = True);

  if (Handled) and (not WebBrowser.Busy) then
  begin
    if FOleInPlaceActiveObject = nil then
    begin
      Dispatch := WebBrowser.Application;
      if Dispatch <> nil then
      begin
        Dispatch.QueryInterface(IOleInPlaceActiveObject, iOIPAO);
        if iOIPAO <> nil then
          FOleInPlaceActiveObject := iOIPAO;
      end;
    end;

    if FOleInPlaceActiveObject <> nil then
      if ((Msg.message = WM_KEYDOWN) or (Msg.message = WM_KEYUP)) and
         (Msg.wParam in [VK_BACK, VK_LEFT, VK_RIGHT]) then
        //nothing - do not pass on Backspace, Left or Right arrows
      else
        FOleInPlaceActiveObject.TranslateAccelerator(Msg);
  end;
end;

// need the initialization/finalization to make  Cut and Copy work
initialization
  OleInitialize(nil);

finalization
  OleUninitialize;
end.
//----------------------------------------------------------------------
----
--------


Hope this helps
Xander van der Merwe


-----Original Message-----
From: Dave O'Brien <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: Thursday, April 29, 1999 10:44 AM
Subject: [DUG]: WebBrowser Component


>I know a few people have asked about this component before, how do I
get
>the TAB key to move between fields in a form in the WebBrowser activex
>component. I've got everything else working fine, and I am trapping the
>TAB keypress in the main form, but what do I do with it? I have looked
>through the type library but cannot find any method of moving the
focus.
>
>This component has taken a lot of my time over the last six months, and
>we are almost ready to launch but for this one problem.
>
>Any help greatly appreciated.
>
>Cheers,
>David O'Brien.
>-----------------------------------------------------------------------
----
>    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                  Website: http://www.delphi.org.nz

------------------------------------------------------------------------
---
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to