mardi 27 octobre 2015

Repeat message in Mouse Proc C++ Win32

I have a procedure that when a user press Ctrl button and right click it will show a message box to screen. But it has a loop, I only press Ctrl button and right click once time but it shows a sequence of message box. How to fix this? https://youtu.be/LzI9M_zEEKQ

This is my MouseProc procedure

    #define EXPORT __declspec(dllexport)
    unsigned char  KeyState[256];

    LRESULT EXPORT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
        if (nCode < 0)
            return CallNextHookEx(hHook, nCode, wParam, lParam);
        GetKeyboardState(KeyState);

        if (nCode == HC_ACTION)
        {
            if ((wParam == WM_RBUTTONUP) && (KeyState[VK_CONTROL] & 0x80))
            {
                MessageBox(NULL, L"Ctrl + Right Click", L"Mouse hook", MB_OK);
            }
        }
        return CallNextHookEx(hHook, nCode, wParam, lParam);
    }

Thanks for reading.

Aucun commentaire:

Enregistrer un commentaire