Thread: Keyboard focus without activation?

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    5

    Keyboard focus without activation?

    Hi, just wondering if anyone knows of a way to give a background window keyboard focus without activating it (and bringing it to the foreground)?

    Currently, I'm using SetWindowPos to push it to the back, which is working well to keep it behind everything else, however, it only gets the mouse events, and I am unable to give it focus (to get key events) without bringing it to the foreground. Tried making the window a child of the desktop window, which screwed up more things than it was worth (though it did solve the focus/background window issue).

    Any ideas?

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I don't know of standard Windows messages will work.
    An easy other way would be to use DirectInput.
    Others might have other suggestions.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    5
    Thanks Elysia, but we are trying to stick to the core win32 api as much as possible, so DirectInput isn't an option at the moment.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You could theoretically place a hook for keyboard messages and monitor them. Heck, you could even steal the messages if you want.
    You can also subclass the current window.
    I don't know how well these options will work.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Activation for mouse and keyboard
    By underline_bruce in forum Windows Programming
    Replies: 1
    Last Post: 09-03-2007, 09:20 AM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Keyboard Focus
    By Aidman in forum Windows Programming
    Replies: 8
    Last Post: 01-07-2003, 05:41 PM
  4. I need help disabling Keyboard and Mouse input on Edit controls
    By Templario in forum Windows Programming
    Replies: 4
    Last Post: 01-07-2003, 12:59 AM
  5. Focus & Always-On-Top :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 06-13-2002, 05:44 PM