Thread: Need to capture the enter key

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    132

    Need to capture the enter key

    Hi, I have a single line editbox that users of my program will type commands into to perform certain tasks. How do I capture the enter key so I know when to grab the text they typed in for processing and then empty to editbox? I can do everything except capturing the enter key.

    Thanks

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    a search would have found this as I have posted it many times.........

    ES_WANTRETURN | ES_MULTILINE
    "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

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    132
    Yes I know that part already, however, what windows message is received when the enter key is hit? This information I haven't been able to find out on my own.

  4. #4

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    132
    okay, but I tried checking it for VK_ENTER and I got an error saying that VK_ENTER wasn't defined. Do you know why this is?

  6. #6
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    VK_RETURN, maybe?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  7. #7
    Registered User
    Join Date
    May 2002
    Posts
    132
    Okay can someone help me with some other problem I am having? I use the following code in my windows procedure:

    Code:
    case WM_KEYDOWN:
    	hFocus = GetFocus();
    	if( hFocus == status.CmdLine || hFocus == status.hWnd ) { // if hWnd has focus.. CmdLine truly has it
    		if( wParam == VK_RETURN ) {
    			// get text inside editbox
    			// pass text into Command()
    			return(0);
    		}
    	}
    	break;
    This code works and all except that now it wont allow me to enter any text into the editbox (which completely defeats the purpose). Any help would be appreciated.

  8. #8
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    If the key wasn't a return, you should really pass the input onto the default handler, rather than just eating the keystroke (which is why the edit control never sees anything)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Window message loop (Keys)
    By Blackroot in forum Windows Programming
    Replies: 3
    Last Post: 09-12-2006, 05:15 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Dialog Edit Control and Enter Key
    By Quantrizi in forum Windows Programming
    Replies: 2
    Last Post: 04-14-2004, 07:59 AM
  4. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  5. Darn enter key...
    By Anonymous in forum C Programming
    Replies: 7
    Last Post: 08-20-2002, 09:07 AM