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. Getting key presses from MFC

Getting key presses from MFC

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
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
    Anonymous
    wrote on last edited by
    #1

    I have a list control and a number of handlers. What I want is to be able to process key presses as well as mouse clicks so if I select an item and press the Delete key on the keyboard I can call my Delete button handler. I have a handler called OnKeydownMyList() which is called when I press a key. How do I find out what key has been pressed so I can call the right handler? Thank you.

    V 1 Reply Last reply
    0
    • A Anonymous

      I have a list control and a number of handlers. What I want is to be able to process key presses as well as mouse clicks so if I select an item and press the Delete key on the keyboard I can call my Delete button handler. I have a handler called OnKeydownMyList() which is called when I press a key. How do I find out what key has been pressed so I can call the right handler? Thank you.

      V Offline
      V Offline
      volkan878
      wrote on last edited by
      #2

      Hi, Your OnKeyDownMyList() looks like this : void Cxxx::OnKeyDownMyList( NMHDR* pNMHDR, LRESULT* pResult ) { LV_KEYDOWN* pLVKeyDow = ( LV_KEYDOWN* ) pNMHDR; *pResult = 0; } Here you can use the wVKey member of the pLVKeyDow.. Example : void Cxxx::OnKeyDownMyList( NMHDR* pNMHDR, LRESULT* pResult ) { LV_KEYDOWN* pLVKeyDow = ( LV_KEYDOWN* ) pNMHDR; if( pLVKeyDow->wVKey == VK_DELETE ) { // Call the function that deletes the selected item... } *pResult = 0; }

      A 1 Reply Last reply
      0
      • V volkan878

        Hi, Your OnKeyDownMyList() looks like this : void Cxxx::OnKeyDownMyList( NMHDR* pNMHDR, LRESULT* pResult ) { LV_KEYDOWN* pLVKeyDow = ( LV_KEYDOWN* ) pNMHDR; *pResult = 0; } Here you can use the wVKey member of the pLVKeyDow.. Example : void Cxxx::OnKeyDownMyList( NMHDR* pNMHDR, LRESULT* pResult ) { LV_KEYDOWN* pLVKeyDow = ( LV_KEYDOWN* ) pNMHDR; if( pLVKeyDow->wVKey == VK_DELETE ) { // Call the function that deletes the selected item... } *pResult = 0; }

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Thank you. That is exactly what I wanted :)

        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