Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. How to get key-down message in a WTL combobox?

How to get key-down message in a WTL combobox?

Scheduled Pinned Locked Moved ATL / WTL / STL
c++helptutorialquestion
4 Posts 4 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    freehawk
    wrote on last edited by
    #1

    Hello everyone: I have a WTL combobox class, but when clicked Enter key, the combobox can not get the key down message, how to get it? Please help me. BTW, I put the combobox in a dialog box and add "WM_KEYDOWN" to the combobox class, but it cannot get this message. -Freehawk

    J N 2 Replies Last reply
    0
    • F freehawk

      Hello everyone: I have a WTL combobox class, but when clicked Enter key, the combobox can not get the key down message, how to get it? Please help me. BTW, I put the combobox in a dialog box and add "WM_KEYDOWN" to the combobox class, but it cannot get this message. -Freehawk

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #2

      Take a look at WM_GETDLGCODE[^] -- Booohoo!

      1 Reply Last reply
      0
      • F freehawk

        Hello everyone: I have a WTL combobox class, but when clicked Enter key, the combobox can not get the key down message, how to get it? Please help me. BTW, I put the combobox in a dialog box and add "WM_KEYDOWN" to the combobox class, but it cannot get this message. -Freehawk

        N Offline
        N Offline
        Nebojsa Mihajlovic
        wrote on last edited by
        #3

        Sorry for late response. Subclass the edit part of combo and catch WM_KEYDOWN from it. in .h file: CContainedWindow m_Edit; ... BEGIN_MSG_MAP(CYourClass) ... ALT_MSG_MAP(1) MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode) MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) MESSAGE_HANDLER(WM_CHAR, OnEditInputMagnification) ... END_MSG_MAP() in .cpp file: in constructor: CYourClass::CYourClass() : m_Edit(_T("EDIT"), this, 1) {} in OnInitDialog: m_Edit.SubclassWindow(::GetWindow(GetDlgItem(IDC_COMBO), GW_CHILD)); add if you want all keys add following: LRESULT CYourClass::OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { return DLGC_WANTALLKEYS; } and finally you can get KeyDown: LRESULT CYourClass::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { switch (wParam) { case VK_RETURN: { ... } break; case VK_TAB: { ... } break; } bHandled = FALSE; return S_OK; }

        K 1 Reply Last reply
        0
        • N Nebojsa Mihajlovic

          Sorry for late response. Subclass the edit part of combo and catch WM_KEYDOWN from it. in .h file: CContainedWindow m_Edit; ... BEGIN_MSG_MAP(CYourClass) ... ALT_MSG_MAP(1) MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode) MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown) MESSAGE_HANDLER(WM_CHAR, OnEditInputMagnification) ... END_MSG_MAP() in .cpp file: in constructor: CYourClass::CYourClass() : m_Edit(_T("EDIT"), this, 1) {} in OnInitDialog: m_Edit.SubclassWindow(::GetWindow(GetDlgItem(IDC_COMBO), GW_CHILD)); add if you want all keys add following: LRESULT CYourClass::OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { return DLGC_WANTALLKEYS; } and finally you can get KeyDown: LRESULT CYourClass::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { switch (wParam) { case VK_RETURN: { ... } break; case VK_TAB: { ... } break; } bHandled = FALSE; return S_OK; }

          K Offline
          K Offline
          kameasha
          wrote on last edited by
          #4

          Still in demand. Thanks,buddy.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups