How to ignore accelerator chars in TWebBrowser (design mode)

痴心易碎 提交于 2020-07-22 05:59:05

问题


I have essentially the same problem like the one described in this question:

How to make TWebBrowser ignore accelerator chars of others controls?

So the TWebBrowser is in design mode and accelerator keys from TAction are executing associated action.

The solution was:

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;

I'd like to try the solution described in the above question but I'm having trouble translating that into C++ Builder code. How do I translate - and - are there other solutions without descending TWebBrowser and overriding CNChar procedure (maybe doing it in the TForm based event)?


回答1:


Translation to C++ Builder (credit to Remy Lebeau).

class TWebBrowser : public Shdocvw::TWebBrowser
{
private:
    MESSAGE void __fastcall CNChar(TWMChar &Message);

public:
    inline __fastcall virtual TWebBrowser(TComponent* AOwner) : Shdocvw::TWebBrowser(AOwner) { }

BEGIN_MESSAGE_MAP
    VCL_MESSAGE_HANDLER(CN_CHAR, TWMChar, CNChar);
END_MESSAGE_MAP(Shdocvw::TWebBrowser)
};

...

void __fastcall TWebBrowser::CNChar(TWMChar &Message)
{
    Message.Result = 0;
}


来源:https://stackoverflow.com/questions/62802874/how-to-ignore-accelerator-chars-in-twebbrowser-design-mode

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