Richard2000
asked on
Tab and Delete keys don't work with TWebBrowser
Hi,
I would like to make the Tab and Delete keys work with TWebBrowser. When these keys are pressed and the TWebBrowser has the focus, nothing happens. I've read in the newsgroups that this is a problem and they say read the FAQs at http://members.home.net/hfournier/. Unfortunately, this site doesn't seem to be working, so I'm stuck.
Would anyone be able to post any Delphi source code to make these keys work correctly within TWebBrowser? Also, do you know if any other keys don't work correctly with TWebBrowser, and if so which?
Thanks in Advance,
Richard
I would like to make the Tab and Delete keys work with TWebBrowser. When these keys are pressed and the TWebBrowser has the focus, nothing happens. I've read in the newsgroups that this is a problem and they say read the FAQs at http://members.home.net/hfournier/. Unfortunately, this site doesn't seem to be working, so I'm stuck.
Would anyone be able to post any Delphi source code to make these keys work correctly within TWebBrowser? Also, do you know if any other keys don't work correctly with TWebBrowser, and if so which?
Thanks in Advance,
Richard
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
Many thanks for the code. I'll take a look at EmbeddedWB too.
Richard
Many thanks for the code. I'll take a look at EmbeddedWB too.
Richard
yes it is a problem ,there are many oher probs with TWebbrowser and it is really better to use the TEmBeddedWb from :
http://www.euromind.com/iedelphi/
it has way better event handling capabilities ..
even cut'n'pate play up with twebbrowser
as for the twebbrowser you can still use t if you wish but it will need an event handler similar to below:
(also similar to what you would find at henry fourniers site).
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtrls, SHDocVw_TLB,ActiveX;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
OIPAO : IOleInPlaceActiveObject;
OIPAO_Wnd:HWND;
public
{ Public declarations }
procedure MyMessageHandler(var Msg: TMsg; var Handled: Boolean);
end;
var
Form1: TForm1;
SaveMessageHandler: TMessageEvent;
implementation
{$R *.DFM}
procedure Tform1.MyMessageHandler(va
const
DuplicatedKeys: set of Byte = [VK_TAB, VK_BACK, VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT];
var
w:HWND;
begin
Handled:=False;
if Msg.message = WM_KEYDOWN then
begin
if Msg.wParam in DuplicatedKeys then
//do nothing let ie take care of it
end;
w:=GetFocus;
if (w=0) {or (w=[].Handle)} then Exit;
if OIPAO<>nil then
begin
if w = OIPAO_Wnd then Handled := IsDialogMessage(w,Msg);
if not Handled then Handled := (OIPAO.TranslateAccelerato
end;
if (not Handled) and Assigned(SaveMessageHandle
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Dispatch:IDispatch;
begin
if assigned(WebBrowser1) then
begin
Dispatch := WebBrowser1.Application_;
if Dispatch<>nil then
begin
Dispatch.QueryInterface(IO
end;
if OIPAO <> nil then OIPAO.GetWindow(OIPAO_Wnd)
end;
SaveMessagehandler := Application.OnMessage;
Application.OnMessage:=MyM
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
OIPAO := nil;
Application.OnMessage := SaveMessageHandler;
end;
procedure TForm1.Button1Click(Sender
begin
opendialog1.execute;
webbrowser1.OleObject.navi
end;
initialization
OleInitialize(nil);
finalization
OleUninitialize;
end.