More Efficient Message Send

This is a discussion on More Efficient Message Send within the Windows Programming forums, part of the Platform Specific Boards category; Ok, well I'm writing this chat program and I have it all functioning, still yet to add features, but I ...

  1. #1
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532

    More Efficient Message Send

    Ok, well I'm writing this chat program and I have it all functioning, still yet to add features, but I want to make it so the text you enter into the edit window will be sent when you hit enter. So you can just type a message and hit enter to send it instead of having to click send. I know two ways I could do this and they seem a bit ridiculous, I think I'm overlooking an easier way and that's why I'm posting. The ways I have in mind are, polling for the enter vk code and when its found send a message to the button to execute its function, OR registering a hotkey, but both of these seem way to inefficient and my question to you is, Is there a better way? Thanks again.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    independent function call function on button and enter key

    Kuphryn

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    If you'd please, would you elaborate a little bit more on those? Thanks for the reply.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Have your button call a function instead of placing all the code in the window/dialog procedure. This way your code that handles the enter key can call the same function instead of having to send a message to the button.

    To trap the enter key you can subclass the edit control. This involves using SetWindowLong to change the edit control's window procedure to your own procedure which traps VK_ENTER and calls the origional window procedure.

  5. #5
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Sounds like a plan, I never thought of making a new window procedure for the edit window, but that's the best way to go, and I do have the code executed by the button in a function already. Thanks!
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Desperate Over Ecs!
    By cookie in forum C Programming
    Replies: 17
    Last Post: 07-16-2008, 02:25 PM
  2. nonblocking send need help
    By sleith in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-27-2008, 11:51 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Making a script language?
    By Blackroot in forum Game Programming
    Replies: 10
    Last Post: 02-16-2006, 02:22 AM
  5. Sending CChildView a Message :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 04-06-2002, 03:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21