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
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Disable back
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Disable back
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
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
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;
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
@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
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
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Disable back
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.
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
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?
And I know how to check for my focus, but I still want to ask if not possible to get chromium thread id?
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Disable back
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"
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"