现在我Backspace键可以用,但是Enter键失效了,代码如下:
var
iOIPAO: IOleInPlaceActiveObject;
Dispatch: IDispatch;
begin
{ exit if we don't get back a webbrowser object }
if WebBrowser1 = nil then
begin
Handled := False;
Exit;
end;
Handled:=(IsDialogMessage(WebBrowser1.Handle, Msg) = True);
//此句是关键,问题是用后Enter键失效,去掉这句Backspace键失效,为什么????
if (Handled) and (not WebBrowser1.Busy) then
begin
if FOleInPlaceActiveObject = nil then
begin
Dispatch := WebBrowser1.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))
((Msg.message >= WM_KEYFIRST) and (Msg.message <=WM_KEYLAST))
and
((Msg.wParam = VK_BACK) or (Msg.wParam = VK_LEFT)
or (Msg.wParam = VK_RIGHT) or(Msg.wParam = VK_TAB) or (Msg.wParam = VK_RETURN)) then
//either write a message handler for the particular message or do
//nothing - do not pass on Backspace, Left or Right arrows or tab
else
FOleInPlaceActiveObject.TranslateAccelerator(Msg);
end;
end;