这是一个例子
//文体框中输入文字时,没法用回车换行,添加事件TApplicationEvents控件
procedure TMainFrm.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
{ fixes the malfunction of some keys within webbrowser control }
const
StdKeys = [VK_TAB, VK_RETURN]
{ standard keys }
ExtKeys = [VK_DELETE, VK_BACK, VK_LEFT, VK_RIGHT]
{ extended keys }
fExtended = $01000000
{ extended key flag }
var
WebBrowser1: TWebBrowser;
begin
if Pages.PageCount = 0 then Exit;
WebBrowser1 := GetCurrentWeb;
Handled := False;
with Msg do
if ((Message >= WM_KEYFIRST) and (Message <= WM_KEYLAST)) and
((wParam in StdKeys) or {$IFDEF VER120}(GetKeyState(VK_CONTROL) < 0) or {$ENDIF}
(wParam in ExtKeys) and ((lParam and fExtended) = fExtended)) then
try
if IsChild(WebBrowser1.Handle, hWnd) then
{ handles all browser related messages }
begin
with WebBrowser1.Application as IOleInPlaceActiveObject do
Handled := TranslateAccelerator(Msg) = S_OK;
if not Handled then
begin
Handled := True;
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
except end;
end;