Killing a focus?

This is a discussion on Killing a focus? within the Windows Programming forums, part of the Platform Specific Boards category; How can I kill a focus, of a control? Thanks...

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Killing a focus?

    How can I kill a focus, of a control?

    Thanks
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One solution is send a WM_KILLFOCUS message to the control.

    SendMessage(hControl, WM_KILLFOCUS, 0);

    Kuphryn

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Another would be to use SetFocus() to set the focus somewhere else.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    What I have is: editbox that I sent text to, and a button. the thing is that when the dialog is called, the text in the editbox is marked, so I did try to set the focus on the button, but no luck.

    The WM_KILLFOCUS doesn't work either
    Last edited by Devil Panther; 07-25-2003 at 12:25 PM.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  5. #5
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    WM_KILLFOCUS is a notification message sent to a window immediately before it loses focus... it doesn't CAUSE it to lose focus. To make something lose focus, tell something else to gain focus via SetFocus(), so the OS knows what to give the focus to. It will then automatically make the control currently in focus lose it, and send it a notification (WM_KILLFOCUS), just in case you need to do something when it no longer has focus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing focus in an MFC Application
    By rangalo in forum Windows Programming
    Replies: 2
    Last Post: 06-20-2005, 06:21 AM
  2. Focus Messages?
    By PsychoBrat in forum Windows Programming
    Replies: 5
    Last Post: 12-30-2003, 06:14 AM
  3. Drawing focus rectangles
    By SMurf in forum Windows Programming
    Replies: 1
    Last Post: 07-29-2002, 08:53 AM
  4. Focus & Always-On-Top :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 06-13-2002, 05:44 PM
  5. Handles invalid when no focus?
    By Fordy in forum Windows Programming
    Replies: 6
    Last Post: 03-15-2002, 07:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21