static std::function<LRESULT(int nCode, WPARAM wParam, LPARAM lParam)> keyProc =
[](int nCode, WPARAM wParam, LPARAM lParam)->LRESULT {
return 1;
};
keyHook = SetWindowsHookEx(WH_KEYBOARD_LL, keyProc, theApp.m_hInstance, NULL);
Error C2664 'HHOOK SetWindowsHookExW(int,HOOKPROC,HINSTANCE,DWORD)': cannot convert argument 2 from 'std::function' to 'HOOKPROC' MFCTest d:\test\mfctest2\mfctest\keymaphooker.cpp 62
PS: Why did I use such a long expression rather than auto? Because I want to it be static.
I changed it to
auto keyProc =
[this](int nCode, WPARAM wParam, LPARAM lParam)->LRESULT {
return 1;//return KeyboardProc(keyHook, keyMap, nCode, wParam, lParam);
};
It doesn't work again.
error C2664: 'HHOOK SetWindowsHookExW(int,HOOKPROC,HINSTANCE,DWORD)': cannot convert argument 2 from 'KeyMapHooker::StartHook::' to 'HOOKPROC'