Thread: Help with hitting 'enter'

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    3

    Help with hitting 'enter'

    Hello guys!

    I'm making a chat application, everything works fine except for that you have to hit the "Send" button with your mouse allways, and you can't use "Enter" to send the message.

    So I'm asking you guys, how would it be possible to allow the enter button to like call some function or make it "click" the Send button?

    I'm using the Win32 API, c++ of course

    Thanks in advance,
    K-Zodron

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    I would handle WM_CHAR messages.. and then respond to '\r'


    Code:
    case WM_CHAR:
        
         switch(wParam)  
         {
              case '\r':  
    
              [respond to ENTER key]
    
              return 0;
    
              [Handle other cases of escape characters...]
    
         }
    Last edited by The Brain; 06-02-2005 at 08:05 AM. Reason: changed 'break' to 'return'
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    3
    Thanks..but it doesn't work really :\
    When I hit "enter", it doesn't call the function I set it to call, and that shows it doesn't really work.

    Maybe I put it in wrong place (:P) ?
    (In WindowProcedure or smth, at least it has many WM_ cases <.<)

  4. #4
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    I changed the 'break' to 'return'.. maybe that will help
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    3
    Quote Originally Posted by The Brain
    I changed the 'break' to 'return'.. maybe that will help
    Didn't help

    Edit: When I changed the WM_CHAR to WM_KEYUP, it works just fine untill I decide to write something on the chat box(I have a default value there, and that gets 'said' when you hit enter before doing anything else)
    Last edited by K-Zodron; 06-02-2005 at 08:24 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With a BlackJack Program in C
    By Jp2009 in forum C Programming
    Replies: 15
    Last Post: 03-30-2009, 10:06 AM
  2. Assignment output help
    By Taka in forum C Programming
    Replies: 13
    Last Post: 09-23-2006, 11:40 PM
  3. Replies: 5
    Last Post: 07-05-2005, 12:37 PM
  4. Hitting enter while FOCUS on an EDIT
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 09-02-2003, 10:26 AM
  5. hi need help with credit limit program
    By vaio256 in forum C++ Programming
    Replies: 4
    Last Post: 04-01-2003, 12:23 AM