Thread: Problems with default buttons

  1. #1
    Registered User
    Join Date
    Mar 2002

    Problems with default buttons

    Hey, I have a dailog with 2 buttons on it. I want it so that when if the use is typing in one of the edit controls that the first button will be selected otherwise the second button is selected. I've got the buttons to change but when I press enter they don't work. Also as soon as you start writing in the edit control the second button changes back to the default button. My code is below.

    case EN_SETFOCUS:
    	SendMessage(GetDlgItem(hwnd, IDC_SEARCH), BM_SETSTYLE, BS_DEFPUSHBUTTON, true);
    	SendMessage(GetDlgItem(hwnd, IDC_DOWNLOAD), BM_SETSTYLE, BS_PUSHBUTTON, true);
    	SendMessage(GetDlgItem(hwnd, IDC_SEARCH), BM_SETSTYLE, BS_PUSHBUTTON, true);
    	SendMessage(GetDlgItem(hwnd, IDC_DOWNLOAD), BM_SETSTYLE, BS_DEFPUSHBUTTON, true);

  2. #2
    Registered User
    Join Date
    May 2002
    I'm not sure about this -

    Try removing the second message from each of the cases. From what I'm reading on MSDN, using BS_DEFPUSHBUTTON will do the job you want, without the need to set the button styles on the other controls..

    It's kind of like an autoradiobutton, it automatically makes itself the only selected one. So those extra messages might be confusing it... and giving you the behavior you described..

    Not sure about that. If I were in your situation I would try that just as an experiment..

  3. #3
    Registered User
    Join Date
    Mar 2002
    Nope doesn't work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Default arguments
    By swgh in forum C Programming
    Replies: 5
    Last Post: 06-29-2007, 06:27 PM
  2. Problems with buttons!! (Help Help)
    By Arkanos in forum Windows Programming
    Replies: 2
    Last Post: 10-16-2005, 12:14 PM
  3. Problems about gcc installation
    By kevin_cat in forum Linux Programming
    Replies: 4
    Last Post: 08-09-2005, 09:05 AM
  4. constructors
    By shrivk in forum C++ Programming
    Replies: 7
    Last Post: 06-24-2005, 09:35 PM
  5. A question about constructors...
    By Wolve in forum C++ Programming
    Replies: 9
    Last Post: 05-04-2005, 04:24 PM