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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Stop default handling of space bar in property sheet?

Stop default handling of space bar in property sheet?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
5 Posts 4 Posters 1 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.
  • I Offline
    I Offline
    IGx89
    wrote on last edited by
    #1

    In my MFC dialog program, the main dialog is a property sheet, with various property pages. When the dialog is open, I want my program to do something special when the user presses (and releases) the space bar. Currently, I'm catching the WM_KEYUP message in my property sheet's PreTranslateMsg function, and returning true if the key is space (the OnKeyUp function doesn't work for some reason). Unfortunately, pressing space also activates the currently selected button, which I definitely don't want. How do I get around that? Thanks!

    R 1 Reply Last reply
    0
    • I IGx89

      In my MFC dialog program, the main dialog is a property sheet, with various property pages. When the dialog is open, I want my program to do something special when the user presses (and releases) the space bar. Currently, I'm catching the WM_KEYUP message in my property sheet's PreTranslateMsg function, and returning true if the key is space (the OnKeyUp function doesn't work for some reason). Unfortunately, pressing space also activates the currently selected button, which I definitely don't want. How do I get around that? Thanks!

      R Offline
      R Offline
      Rand Althor
      wrote on last edited by
      #2

      :rolleyes:I would say, you should override the OnKeyDown() function instead. Within that function, check the nChar parameter, and if it is the keyboard button, do your thing, then exit without calling the base class implementation. Or call the baseclass implementation, but change the value of nChar to somnething else that wouldn't be a problem for you. Get back to us on that, please. Two Rivers!

      I S 2 Replies Last reply
      0
      • R Rand Althor

        :rolleyes:I would say, you should override the OnKeyDown() function instead. Within that function, check the nChar parameter, and if it is the keyboard button, do your thing, then exit without calling the base class implementation. Or call the baseclass implementation, but change the value of nChar to somnething else that wouldn't be a problem for you. Get back to us on that, please. Two Rivers!

        I Offline
        I Offline
        IGx89
        wrote on last edited by
        #3

        I wasn't able to get my OnKeyUp/Down functions working (in the sheet OR page), so I'm just catching the WM_KEYUP/DOWN in PreTranslateMsg in the sheet. I finally got it working, by returning true (that function) if the key was pressed down, and by performing the action when the key was released. I thought I tried that before, but oh well :) Thanks for the reply! :)

        1 Reply Last reply
        0
        • R Rand Althor

          :rolleyes:I would say, you should override the OnKeyDown() function instead. Within that function, check the nChar parameter, and if it is the keyboard button, do your thing, then exit without calling the base class implementation. Or call the baseclass implementation, but change the value of nChar to somnething else that wouldn't be a problem for you. Get back to us on that, please. Two Rivers!

          S Offline
          S Offline
          Sean_Yang
          wrote on last edited by
          #4

          I am not using MFC stuff at all. How would overriding OnKeyDown() work? Thanks for the answer. Thanks Sean

          A 1 Reply Last reply
          0
          • S Sean_Yang

            I am not using MFC stuff at all. How would overriding OnKeyDown() work? Thanks for the answer. Thanks Sean

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

            Well, you check the parameter passed to this function, and if it's a "whatever you want" you don't call the base class implementation, isntead call whatever you need. I thoguh it would be pretty obvious"? After all, it's the point (and power) of C++ operator overloading.

            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