OnTranslateAccelerator

Here is your chance to take control over your webbrowser's use of the acceleratorkeys. By default a number of Ctrl-keys are active. E.g. Ctrl-N opens a new window and Ctrl-P opens Print-Dialog.


Disable all acceleratorkeys:

To disable all the default acceleratorkeys return S_OK as result of this function:

function TForm1.EmbeddedWB1TranslateAccelerator(const lpMsg: PMsg;
const pguidCmdGroup: PGUID; const nCmdID: Cardinal): HRESULT;
begin
result := S_OK;
end;

 

Disable some accelerators:

The following code disable the IE4/IE5 default Ctrl-N shortcut (Open New Window):

function TForm1.EmbeddedWB1TranslateAccelerator(const lpMsg: PMsg;
const pguidCmdGroup: PGUID; const nCmdID: Cardinal): HRESULT;
begin
if (getkeystate(VK_CONTROL) < 0) and (lpmsg.wParam = Ord('N')) then
result := S_OK else result := S_FALSE;
end;

 

Add acceleratorkeys:

Adding new shortcuts:

Add Alt-P to open Page Setup Dialog

function TForm1.EmbeddedWB1TranslateAccelerator(const lpMsg: PMsg;
const pguidCmdGroup: PGUID; const nCmdID: Cardinal): HRESULT;
begin
if (getkeystate(VK_ALT) < 0) and (lpmsg.wParam = Ord('P')) then
Embeddedwb1.PageSetup else result:=S_FALSE;
end;

Remember that TranslateAccelerator is called extremely often, so make it short and do not place your auto-biography in this function.