Make mouse hook functions right
This commit is contained in:
parent
28c9bb6d31
commit
8a01e5e29b
@ -41,26 +41,25 @@ using namespace std;
|
|||||||
static HWND hWndServer = NULL;
|
static HWND hWndServer = NULL;
|
||||||
static HHOOK hookMouse = NULL;
|
static HHOOK hookMouse = NULL;
|
||||||
|
|
||||||
static LRESULT CALLBACK hookProcMouse(UINT nCode, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK hookProcMouse(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if(nCode < 0)
|
if (nCode >= 0)
|
||||||
{
|
{
|
||||||
::CallNextHookEx(hookMouse, nCode, wParam, lParam);
|
switch (wParam)
|
||||||
return 0;
|
{
|
||||||
}
|
|
||||||
|
|
||||||
switch (wParam)
|
|
||||||
{
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
case WM_NCMOUSEMOVE:
|
case WM_NCMOUSEMOVE:
|
||||||
::PostMessage(hWndServer, UINT(wParam), 0, 0);
|
::PostMessage(hWndServer, UINT(wParam), 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_NCLBUTTONUP:
|
case WM_NCLBUTTONUP:
|
||||||
::PostMessage(hWndServer, UINT(wParam), 0, 0);
|
::PostMessage(hWndServer, UINT(wParam), 0, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ::CallNextHookEx(hookMouse, nCode, wParam, lParam);
|
return ::CallNextHookEx(hookMouse, nCode, wParam, lParam);
|
||||||
@ -218,7 +217,6 @@ void DockingCont::setActiveTb(tTbData* pTbData)
|
|||||||
|
|
||||||
void DockingCont::setActiveTb(int iItem)
|
void DockingCont::setActiveTb(int iItem)
|
||||||
{
|
{
|
||||||
//if ((iItem != -1) && (iItem < ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0)))
|
|
||||||
if (iItem < ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0))
|
if (iItem < ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0))
|
||||||
{
|
{
|
||||||
selectTab(iItem);
|
selectTab(iItem);
|
||||||
@ -302,7 +300,7 @@ LRESULT DockingCont::runProcCaption(HWND hwnd, UINT Message, WPARAM wParam, LPAR
|
|||||||
|
|
||||||
// start hooking
|
// start hooking
|
||||||
hWndServer = _hCaption;
|
hWndServer = _hCaption;
|
||||||
hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)hookProcMouse, _hInst, 0);
|
hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, hookProcMouse, _hInst, 0);
|
||||||
|
|
||||||
if (!hookMouse)
|
if (!hookMouse)
|
||||||
{
|
{
|
||||||
|
@ -42,10 +42,10 @@ BOOL DockingManager::_isRegistered = FALSE;
|
|||||||
static HWND hWndServer = NULL;
|
static HWND hWndServer = NULL;
|
||||||
//Next hook in line
|
//Next hook in line
|
||||||
static HHOOK gWinCallHook = NULL;
|
static HHOOK gWinCallHook = NULL;
|
||||||
LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam);
|
LRESULT CALLBACK focusWndProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
// Callback function that handles messages (to test focus)
|
// Callback function that handles messages (to test focus)
|
||||||
LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK focusWndProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (nCode == HC_ACTION && hWndServer)
|
if (nCode == HC_ACTION && hWndServer)
|
||||||
{
|
{
|
||||||
@ -164,7 +164,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin)
|
|||||||
hWndServer = _hSelf;
|
hWndServer = _hSelf;
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
if (!gWinCallHook) //only set if not already done
|
if (!gWinCallHook) //only set if not already done
|
||||||
gWinCallHook = ::SetWindowsHookEx(WH_CALLWNDPROC, FocusWndProc, hInst, GetCurrentThreadId());
|
gWinCallHook = ::SetWindowsHookEx(WH_CALLWNDPROC, focusWndProc, hInst, GetCurrentThreadId());
|
||||||
|
|
||||||
if (!gWinCallHook)
|
if (!gWinCallHook)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ static HHOOK hookMouse = NULL;
|
|||||||
#define WH_MOUSE_LL 14
|
#define WH_MOUSE_LL 14
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static LRESULT CALLBACK hookProcMouse(UINT nCode, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK hookProcMouse(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if(nCode >= 0)
|
if(nCode >= 0)
|
||||||
{
|
{
|
||||||
@ -52,10 +52,12 @@ static LRESULT CALLBACK hookProcMouse(UINT nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_NCMOUSEMOVE:
|
case WM_NCMOUSEMOVE:
|
||||||
::PostMessage(hWndMouse, static_cast<UINT>(wParam), 0, 0);
|
::PostMessage(hWndMouse, static_cast<UINT>(wParam), 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_NCLBUTTONUP:
|
case WM_NCLBUTTONUP:
|
||||||
::PostMessage(hWndMouse, static_cast<UINT>(wParam), 0, 0);
|
::PostMessage(hWndMouse, static_cast<UINT>(wParam), 0, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -151,7 +153,7 @@ LRESULT DockingSplitter::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
{
|
{
|
||||||
hWndMouse = hwnd;
|
hWndMouse = hwnd;
|
||||||
hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, reinterpret_cast<HOOKPROC>(hookProcMouse), _hInst, 0);
|
hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, hookProcMouse, _hInst, 0);
|
||||||
if (!hookMouse)
|
if (!hookMouse)
|
||||||
{
|
{
|
||||||
DWORD dwError = ::GetLastError();
|
DWORD dwError = ::GetLastError();
|
||||||
|
@ -51,7 +51,7 @@ static HWND hWndServer = NULL;
|
|||||||
static HHOOK hookMouse = NULL;
|
static HHOOK hookMouse = NULL;
|
||||||
static HHOOK hookKeyboard = NULL;
|
static HHOOK hookKeyboard = NULL;
|
||||||
|
|
||||||
static LRESULT CALLBACK hookProcMouse(INT nCode, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK hookProcMouse(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (nCode >= 0)
|
if (nCode >= 0)
|
||||||
{
|
{
|
||||||
@ -61,10 +61,12 @@ static LRESULT CALLBACK hookProcMouse(INT nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_NCMOUSEMOVE:
|
case WM_NCMOUSEMOVE:
|
||||||
::SendMessage(hWndServer, static_cast<UINT>(wParam), 0, 0);
|
::SendMessage(hWndServer, static_cast<UINT>(wParam), 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_NCLBUTTONUP:
|
case WM_NCLBUTTONUP:
|
||||||
::SendMessage(hWndServer, static_cast<UINT>(wParam), 0, 0);
|
::SendMessage(hWndServer, static_cast<UINT>(wParam), 0, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -72,7 +74,7 @@ static LRESULT CALLBACK hookProcMouse(INT nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
return ::CallNextHookEx(hookMouse, nCode, wParam, lParam);
|
return ::CallNextHookEx(hookMouse, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK hookProcKeyboard(INT nCode, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK hookProcKeyboard(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (nCode >= 0)
|
if (nCode >= 0)
|
||||||
{
|
{
|
||||||
@ -258,7 +260,7 @@ void Gripper::create()
|
|||||||
::SetWindowPos(_pCont->getHSelf(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
::SetWindowPos(_pCont->getHSelf(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||||
::SetCapture(_hSelf);
|
::SetCapture(_hSelf);
|
||||||
winVer ver = (NppParameters::getInstance())->getWinVersion();
|
winVer ver = (NppParameters::getInstance())->getWinVersion();
|
||||||
hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)hookProcMouse, _hInst, 0);
|
hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, hookProcMouse, _hInst, 0);
|
||||||
|
|
||||||
if (!hookMouse)
|
if (!hookMouse)
|
||||||
{
|
{
|
||||||
@ -270,7 +272,7 @@ void Gripper::create()
|
|||||||
|
|
||||||
if (ver != WV_UNKNOWN && ver < WV_VISTA)
|
if (ver != WV_UNKNOWN && ver < WV_VISTA)
|
||||||
{
|
{
|
||||||
hookKeyboard = ::SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)hookProcKeyboard, _hInst, 0);
|
hookKeyboard = ::SetWindowsHookEx(WH_KEYBOARD_LL, hookProcKeyboard, _hInst, 0);
|
||||||
if (!hookKeyboard)
|
if (!hookKeyboard)
|
||||||
{
|
{
|
||||||
DWORD dwError = ::GetLastError();
|
DWORD dwError = ::GetLastError();
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
int TaskListDlg::_instanceCount = 0;
|
int TaskListDlg::_instanceCount = 0;
|
||||||
|
|
||||||
LRESULT CALLBACK hookProc(UINT nCode, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK hookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if ((nCode >= 0) && (wParam == WM_RBUTTONUP))
|
if ((nCode >= 0) && (wParam == WM_RBUTTONUP))
|
||||||
{
|
{
|
||||||
@ -98,7 +98,7 @@ INT_PTR CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP
|
|||||||
#ifndef WH_MOUSE_LL
|
#ifndef WH_MOUSE_LL
|
||||||
#define WH_MOUSE_LL 14
|
#define WH_MOUSE_LL 14
|
||||||
#endif
|
#endif
|
||||||
_hHooker = ::SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)hookProc, _hInst, 0);
|
_hHooker = ::SetWindowsHookEx(WH_MOUSE_LL, hookProc, _hInst, 0);
|
||||||
hook = _hHooker;
|
hook = _hHooker;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user