vendredi 8 juin 2018

pass lambda as Windows CALLBACK function failed

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.

Aucun commentaire:

Enregistrer un commentaire