Is it possible that in file cefclient_win.cpp
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
mouse messages are filtered out, as I only get WM_MOUSEMOVE message through?
It seems like left or right clicks are handled before the WndProc gets a hold of them. How do I disable right mouse click in particular?
The way I solved it was by adding a mouse hook to the thread created by CEF for each browser window:
// Hook to disable right mouse clicks
LRESULT CALLBACK MyMouseHook(int nCode, WPARAM wp, LPARAM lp)
{
MOUSEHOOKSTRUCT *pmh = (MOUSEHOOKSTRUCT *) lp;
if (nCode >= 0) {
if( wp == WM_RBUTTONDOWN || wp == WM_RBUTTONUP ) {
return 1;
}
}
return CallNextHookEx(NULL, nCode, wp, lp);
}
void
CefBrowserApplication::OnCreate(
CefRefPtr<CefBrowserClientHandler> aBrowserClient)
{
// Hook the mouse
DWORD threadId = GetWindowThreadProcessId(aBrowserClient->GetBrowser()->GetWindowHandle(), NULL);
HHOOK hook = SetWindowsHookEx(WH_MOUSE, MyMouseHook, NULL, threadId);
}
Note that I'm not using a low level mouse hook, since those are global for the entire desktop. Disabling right mouse clicks in a global low level hook would disable it for all running applications.