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. Key Entry

Key Entry

Scheduled Pinned Locked Moved C / C++ / MFC
c++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.
  • M Offline
    M Offline
    Mike Winter
    wrote on last edited by
    #1

    Hi again! I now have another (simple) problem! I have a dialog box with a listbox control on it, which has been loaded with several strings. I want to be able to select a string, and then delete it by pressing the key. I havnt been able to detect any key being pressed. What do I need to do? I have used MFC Classwizard to add message handlers for WM_KEY_DOWN and WM_KEY_UP, but it doesnt seam to work - where am I going wrong? Thanks yet again!

    K 1 Reply Last reply
    0
    • M Mike Winter

      Hi again! I now have another (simple) problem! I have a dialog box with a listbox control on it, which has been loaded with several strings. I want to be able to select a string, and then delete it by pressing the key. I havnt been able to detect any key being pressed. What do I need to do? I have used MFC Classwizard to add message handlers for WM_KEY_DOWN and WM_KEY_UP, but it doesnt seam to work - where am I going wrong? Thanks yet again!

      K Offline
      K Offline
      khan
      wrote on last edited by
      #2

      You can subclass the control. Create message handler for WM_KEYUP message:

      void ..... OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
      {
      if (nChar == VK_DELETE)
      {
      //delete the string here.
      }

      CListBox::OnKeyUp(nChar, nRepCnt, nFlags);
      

      }

      Maybe there are better ways. this is this.

      M 1 Reply Last reply
      0
      • K khan

        You can subclass the control. Create message handler for WM_KEYUP message:

        void ..... OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
        {
        if (nChar == VK_DELETE)
        {
        //delete the string here.
        }

        CListBox::OnKeyUp(nChar, nRepCnt, nFlags);
        

        }

        Maybe there are better ways. this is this.

        M Offline
        M Offline
        Mike Winter
        wrote on last edited by
        #3

        Hi Khan++ Thanks for your help - yep thats got it now! Thanks again Mike

        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