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. C / C++ / MFC
  4. ListBoxes and the magic of VKeyToItem()

ListBoxes and the magic of VKeyToItem()

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    Andrew Stampor
    wrote on last edited by
    #1

    I would like to capture when the user hits the return key when an item in the listbox is selected. However, it would seem that CListBox::VKeyToItem() captures most keystrokes, but only provides an irritating "beep" when I hit return. What I would like to do is to have the enter key register like a LBN_DBLCLK. Even if CListBox::VKeyToItem() did accept the return key, would it even be possible to have it enable items outside of the CListBox derived class I created?:confused: Any help is greatly appreciated. Thanks in advance.

    R 1 Reply Last reply
    0
    • A Andrew Stampor

      I would like to capture when the user hits the return key when an item in the listbox is selected. However, it would seem that CListBox::VKeyToItem() captures most keystrokes, but only provides an irritating "beep" when I hit return. What I would like to do is to have the enter key register like a LBN_DBLCLK. Even if CListBox::VKeyToItem() did accept the return key, would it even be possible to have it enable items outside of the CListBox derived class I created?:confused: Any help is greatly appreciated. Thanks in advance.

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Does your list box have the style LBS_WANTKEYBOARDINPUT?  If so, OnVKeyToItem() should look something like this:

      save status of base class CWnd::OnVKeyToItem() call;
      get coords of index of item;
      post WM_RBUTTONDBLCLK using those coordinates;
      return status;

      /ravi "There is always one more bug..." ravib@cadence.com http://www.ravib.com

      A 1 Reply Last reply
      0
      • R Ravi Bhavnani

        Does your list box have the style LBS_WANTKEYBOARDINPUT?  If so, OnVKeyToItem() should look something like this:

        save status of base class CWnd::OnVKeyToItem() call;
        get coords of index of item;
        post WM_RBUTTONDBLCLK using those coordinates;
        return status;

        /ravi "There is always one more bug..." ravib@cadence.com http://www.ravib.com

        A Offline
        A Offline
        Andrew Stampor
        wrote on last edited by
        #3

        Yes, I have LBS_WANTKEYBOARDINPUT. But, it does not seem that OnVKeyToItem is called when the enter key is hit. That is where I am having a major problem. Thanks, though.

        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