解决Webbrowser加载Flash后,方向键等冲突

主窗体上放一个ApplicationEvent控件,OnMessage事件中这么写:

 

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean); const StdKeys = [VK_TAB, VK_RETURN, VK_BACK]; { standard keys } ExtKeys = [VK_DELETE, VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN]; { extended keys } fExtended = $01000000; { extended key flag } var CurrentEWB: TEmbeddedWB; begin Handled := False; CurrentEWB := EmbeddedWB1; if Assigned(CurrentEWB) then if IsChild(CurrentEWB.Handle, Msg.Hwnd) then begin Handled := (IsDialogMessage(CurrentEWB.Handle, Msg) = True); if Handled and not CurrentEWB.Busy then if ((Msg.Message >= WM_KEYFIRST) and (Msg.Message <= WM_KEYLAST)) and ((Msg.wParam in StdKeys) or (GetKeyState(VK_CONTROL) < 0) or (Msg.wParam in ExtKeys) and ((Msg.lParam and fExtended) = fExtended)) then begin Handled := (CurrentEWB.Application as IOleInPlaceActiveObject).TranslateAccelerator(Msg) = S_OK; if not Handled then begin Handled := True; TranslateMessage(Msg); DispatchMessage(Msg); end; end; end; end;

你可能感兴趣的:(Delphi(转帖))