Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3046

Do not receive focus events in console

$
0
0
Hi There,

I thought this must have been asked many times. I use something like:
Code:

    static HANDLE stdinHandle = GetStdHandle(STD_INPUT_HANDLE);

    const DWORD consoleInputCommandMode = ENABLE_ECHO_INPUT + ENABLE_PROCESSED_INPUT;
    SetConsoleMode(stdinHandle, consoleInputCommandMode);
    FlushConsoleInputBuffer(stdinHandle);

    INPUT_RECORD record;
    DWORD numRead;

    switch (WaitForSingleObject(stdinHandle, 1000)) {
        case(WAIT_OBJECT_0):
        if (ReadConsoleInput(stdinHandle, &record, 1, &numRead)) {
            if (record.EventType != KEY_EVENT) {
// THIS IS THE PROBLEM, I just want key events, nothing else
            }
        }
            break;
    }

I could disable mouse events but MENU_EVENT 0x0008 and FOCUS_EVENT 0x0010 keep coming.

How can I get rid of those - I cannot see an option in SetConsoleMode;

Thank you :)

Viewing all articles
Browse latest Browse all 3046

Trending Articles