CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    May 2002
    Location
    Germany
    Posts
    451

    Do not receive focus events in console

    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
    Last edited by luftwaffe; December 12th, 2023 at 03:34 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured