Thread: Set Keyboard Focus to a non child control

  1. #1
    Registered User
    Join Date
    Dec 2010
    Location
    Delhi, India
    Posts
    59

    Set Keyboard Focus to a non child control

    Hi, I am stuck in a problem where I have to set keyboard focus on a rectangle ( means I should get WM_KEYDOWN and WM_KEYUP when I press the key). You can think of it as the keyboard handling we get in a calendar (like in MS Outlook). I have a modal dialog and several rectangles (which are not any controls) and I want to fill each of them with a color when the keyboard focus goes from one to another.
    Any suggestions would be appreciated.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Use STATIC controls, with the SS_NOTIFY style.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Location
    Delhi, India
    Posts
    59
    Thanks for answering.. it seems that I will have to rewrite a lot of my code.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by gaurav_13191 View Post
    Thanks for answering.. it seems that I will have to rewrite a lot of my code.
    You might be getting WM_MOUSEMOVE from the parent window and you could perhaps work out some other means for the keyboard problem.

    But static controls make this a lot easier... you can TAB to them and if you use the WM_GROUP style you can isolate them for use with the arrow keys far easier... Changing the colors can be handled with the WM_CTLCOLORSTATIC message...

    So I think it would be a lot simpler to just make a bunch of static controls and work from there...


    As for rewriting big chunks of code... my friend that's life... happens all the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. catch hotkeys while not active keyboard focus
    By zeroth in forum Linux Programming
    Replies: 2
    Last Post: 12-15-2009, 05:25 PM
  2. Keyboard focus without activation?
    By kgen in forum Windows Programming
    Replies: 3
    Last Post: 01-07-2008, 02:25 PM
  3. Child looses focus in a couple of seconds.
    By Yarin in forum Windows Programming
    Replies: 5
    Last Post: 12-29-2007, 04:36 PM
  4. Ensuring That Main Child Window Receives Focus
    By SMurf in forum Windows Programming
    Replies: 3
    Last Post: 08-28-2006, 05:32 AM
  5. Keyboard Focus
    By Aidman in forum Windows Programming
    Replies: 8
    Last Post: 01-07-2003, 05:41 PM