sending enter key message to window

This is a discussion on sending enter key message to window within the Windows Programming forums, part of the Platform Specific Boards category; I have the handle names of a edit box which is a child of a combo box. these two controls ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    24

    sending enter key message to window

    I have the handle names of a edit box which is a child of a combo box. these two controls are in another application.

    using:

    Code:
    SendMessage(txtBox, WM_SETTEXT, NULL, (LPARAM)(LPCTSTR)response);
    I can place text in the edit box. Now i need to send the enter key message to the edit box, I have tried:
    Code:
    SendMessage(txtBox, WM_KEYDOWN, VK_RETURN, 0);
    SendMessage(txtBox, WM_KEYUP,  VK_RETURN, 0);
    Code:
    PostMessage(txtBox, WM_CHAR, VK_RETURN, 0);
    Code:
    SendMessage(txtBox, WM_CHAR, VK_RETURN, 0);
    Code:
    PostMessage(txtBox, WM_KEYDOWN, VK_RETURN, 0);
    PostMessage(txtBox, WM_KEYUP, VK_RETURN, 0);
    Code:
    keybd_event(VK_RETURN, 0,0,0);
    keybd_event(13, 0,KEYEVENTF_KEYUP,0);
    None of which worked. I use Borland C++ 3, Win 2000

    Any ideas?
    thanks

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    1. Just a tip, it's probably better to prefix handle names with 'h'. It just allows you to tell that it's a handle straight away.

    2. I think you may have to send the enter message to a different part of the control. Normally, single-line edit controls don't receive enter key messages, they're redirected elsewhere. Try sending it to the overall control.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    You should understand the difference between notifications and actual events. Most of the messages you are attempting to send to the control are notifications. These are messages that are sent to windows after something has happened. It notifies them, in case they wish to do something in response to it. They do not emulate the event which has happened.

    As an example, the SetFocus() function changes the focus, whereas WM_KILLFOCUS is simply a notification to tell that window that the focus has been lost. It cannot be sent to force it to lose focus.

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, 06:15 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Making dialog box the only window
    By PJYelton in forum Windows Programming
    Replies: 2
    Last Post: 09-06-2005, 01:02 PM
  4. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 06:48 PM
  5. opengl help
    By heat511 in forum Game Programming
    Replies: 4
    Last Post: 04-05-2004, 02:08 AM

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