Page 1 of 1

Disable back

Posted: Mon Aug 26, 2019 1:20 pm
by dinko
Is there any way to completely disable back ? My main problem is user pressing mouse's back button and I want to avoid as the page is in a kiosk system.

Thanks

Re: Disable back

Posted: Mon Aug 26, 2019 1:42 pm
by salvadordf
Hi,

I don't have navigation buttons in my mouse and I can't test it but try this :
https://www.briskbard.com/forum/viewtop ... 826&p=3689

Re: Disable back

Posted: Mon Aug 26, 2019 2:18 pm
by dinko
Thanks! After reading everything, I found the best way to completely disable in Delphi level


hkk := SetWindowsHookEx(WH_MOUSE_LL, @MouseHook, 0, 0);

...

function MouseHook(code: Integer; wparam: WPARAM; lparam: LPARAM): LRESULT; stdcall;
var
a: TMOUSEHOOKSTRUCT;
begin
if code < 0 then
Result := CallNextHookEx(hkk,code,wparam,lparam)
// discard all right button related mouse messages
else if (wParam = WM_MBUTTONDOWN) or (wParam = WM_XBUTTONUP) or (wParam = WM_XBUTTONDOWN) then
Result := 1
else
Result := 0;
end;

Re: Disable back

Posted: Mon Sep 02, 2019 2:58 pm
by dinko
@salvadordf,

i have a small problem with this approach. It totally blocks mouse buttons in the entire system not only in my app.
I found out that

hkk := SetWindowsHookEx(WH_MOUSE_LL, @MouseHook, HInstance, 0);

has to change to

hkk := SetWindowsHookEx(WH_MOUSE_LL, @MouseHook, HInstance, GetCurrentThreadID);

But now buttons work both in my app and in global. It looks like GetCurrentThreadID is wrong because chromium has its own thread id, am I wrong? How should I found out the chromium thread id so I can hook only to this window?

I load it as single process

GlobalCEFApp.SingleProcess := true;

Thanks

Re: Disable back

Posted: Mon Sep 02, 2019 3:18 pm
by salvadordf
Try blocking the message only if your application is focused.
https://stackoverflow.com/questions/371 ... -has-focus

Please, use the SingleProcess mode only for debugging purposes. It's a known cause of unexpected errors.

Re: Disable back

Posted: Mon Sep 02, 2019 3:24 pm
by dinko
Yes I know Single Process causes problems dont worry.
And I know how to check for my focus, but I still want to ask if not possible to get chromium thread id?

Re: Disable back

Posted: Mon Sep 02, 2019 3:39 pm
by salvadordf
I'm not sure what Chromium thread would be used for this.
I guess that the thread referenced as UI by the CEF documents would be a good candidate.

A simple way to get that ID would be to call "GetThreadID" inside any TChromium event that is executed in that thread, for example TChromium.OnAfterCreated.

Chromium creates many more threads as you can see in the debugger or in the "Sysinternals Process Explorer"