1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

trap vk_return within combo box

Discussion in 'Win32' started by hobbyist, Nov 7, 2014.

  1. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    shabbir, if you've got a few minutes, I was wondering if you could help me with trapping the VK_RETURN message.

    I've created the combo box as

    Code:
    CreateWindow(TEXT("COMBOBOX"), TEXT(""),
           WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | 
           CBS_HASSTRINGS | CBS_DROPDOWN,
           82, 220, 100, 20,
           hwnd, (HMENU)myIDC_WILDCARD, global_instance, NULL);
    
    This gets created / destroyed during tab control changes. What I'm hoping to do is when the user types a string in the edit portion and hits return, I add the string to the list. My problem is that I cannot seem to catch the VK_RETURN message. \n doesn't seem to be present in the user's string during CBN_EDITCHANGE

    Is VK_RETURN sent to the combox box, the edit portion, or maybe the tab or even parent? Sub classing has proven to be a major headache for a layman like myself. :D Any ideas?
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    VK_RETURN may not be present in the string because it sends triggers other events. Like when pressing tab means it looses focus and so in that event handler you have to make such that focus is driven back to the control. Similarly for Enter or return.

    Not sure but does that control support multiline - ES_MULTILINE?

    If it does not support that then you may not be able to get those in the string. If it does then you may enable that and then enter may work like normal and will be part of the string.
     
  3. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    Thank you for the reply - I appreciate it.

    It doesn't look like ES_MULTILINE has any effect; from MS, it *looks* like subclassing is the only way to determine whether or not return was pressed. I couldn't figure out the sub class procedure though as it completely trashed my tab... I just don't know enough to work with it.

    I decided to scan the input string for a designated character instead.
     

Share This Page