How to make TWebBrowser ignore accelerator chars of others controls?

北慕城南 提交于 2020-08-03 03:25:11

问题


I have a TWebBrowser placed on a form with the designMode enabled.
Bellow the browser I have a close button with the Caption set to 'Clos&e'.
When I am editing the contents of a document inside the WebBrowser and I press the key E the button close is called.
It appears that it is treating TWebBrowser like other controls that don't handle keys and/or don't accept chars (e.g. TButton).

How can I solve this?

Thanks in advance.


回答1:


Descend from TWebBrowser, override the CN_CHAR message handler, and return 0. Triggering the shortcut with Alt+E will still work.

type
  TWebBrowser = class(SHDocVw.TWebBrowser)
    procedure CNChar(var Message: TWMChar); message CN_CHAR;
  end;

...

procedure TWebBrowser.CNChar(var Message: TWMChar);
begin
  Message.Result := 0;
end;


来源:https://stackoverflow.com/questions/2602239/how-to-make-twebbrowser-ignore-accelerator-chars-of-others-controls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!