Thread: How to kill focus of MFC Wizard buttons

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    How to kill focus of MFC Wizard buttons

    I'm developing a MFC wizard base application. When the application load, it automatically focus to thecancel button. If the user press enter key, then the application exit unexpectedly. Then I set the focus to a text box appear in the inner dialog using cedit.setFocus(). but when I type using keyboard it focus the text field, but If I press enter still focus to cancel button.
    In simply is there anyway to set and kill focus of the MFC wizard buttons

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Sounds like your CANCEL button has the BS_DEFPUSHBUTTON style.

    This means that when the user clicks ENTER the button will get a BN_CLICKED msg, even if it does not have focus.

    Try removing the BS_DEFPUSHBUTTON.

    BTW...

    For an EDIT control to get ENTER key messages it needs both the ES_WANTRETURN and ES_MULTILINE styles (if I recall the styles names correctly...)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dont Kill Focus When Switching Tasks
    By stickman in forum Windows Programming
    Replies: 6
    Last Post: 11-17-2006, 09:08 PM
  2. The hit wizard?
    By Fahrenheit in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 11-23-2003, 09:45 AM
  3. Wizard
    By nbo10 in forum Windows Programming
    Replies: 1
    Last Post: 07-30-2003, 02:31 AM
  4. whose the c++ wizard
    By tam in forum C++ Programming
    Replies: 4
    Last Post: 07-26-2002, 03:10 AM