Thread: Buttons In Dialog Boxes

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    73

    Buttons In Dialog Boxes

    I have a button in my dialog box that when you click it the dialog box quits. However, it would be really nice if when I hit the enter/return key it would also quit the program. Can someone help me out? I'm using MSVC++ and the dialog box is in a resource file.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Check out WM_KEYDOWN or WM_CHAR.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Your default button should be a DEFPUSHBUTTON and you should have IsDialogMessage in your message loop. If you meet these two conditions, and the currently focused control does not use the enter key press, the dialog manager will "click" your default button when enter is pressed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Common Dialog boxes GetOpenFileName()
    By A10 in forum Windows Programming
    Replies: 3
    Last Post: 09-02-2008, 08:56 PM
  2. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  3. Dialog Boxes
    By Thantos in forum Windows Programming
    Replies: 7
    Last Post: 08-26-2003, 12:49 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM