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. Why does a MFC Dialog ding?

Why does a MFC Dialog ding?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++
3 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I have a basic MFC app. Basically, you can start the MFC appwizard, choose Dialog Based, and arrive at a dialog. Now, I want the dialog to monitor they keys pressed on the keyboard (some keys in combination), so I use GetKeyboardState(). The problem is whenever I hit a key it dings. I've attempted to override the WM_KEYDOWN, CHAR and other relative messages. Furthermore, I seem to fail to set the focus away from the OK button by using SetFocus() in the OnInitDialog(). When I remove ALL the controls, the dialog finally gets my WM_KEYDOWN events. I should be able to set the dialog to receive events even with controls on it shouldn't I? But I digress. The only reason why I'm attempting to override those events is because of the dinging. My goal is to make an app in MFC where I can use the keyboard to modify a state structure via quake-like key bindings. I think once I fix the dinging, I'll be happy. Thanks in Adavance

    E W 2 Replies Last reply
    0
    • L Lost User

      I have a basic MFC app. Basically, you can start the MFC appwizard, choose Dialog Based, and arrive at a dialog. Now, I want the dialog to monitor they keys pressed on the keyboard (some keys in combination), so I use GetKeyboardState(). The problem is whenever I hit a key it dings. I've attempted to override the WM_KEYDOWN, CHAR and other relative messages. Furthermore, I seem to fail to set the focus away from the OK button by using SetFocus() in the OnInitDialog(). When I remove ALL the controls, the dialog finally gets my WM_KEYDOWN events. I should be able to set the dialog to receive events even with controls on it shouldn't I? But I digress. The only reason why I'm attempting to override those events is because of the dinging. My goal is to make an app in MFC where I can use the keyboard to modify a state structure via quake-like key bindings. I think once I fix the dinging, I'll be happy. Thanks in Adavance

      E Offline
      E Offline
      Erik Funkenbusch
      wrote on last edited by
      #2

      In order to use SetFocus() in OnInitDialog(), you need to return FALSE from the OnInitDialog() function (as it says in the comment at the bottom of the function) You can also trap key events in PreTranslateMsg function.

      1 Reply Last reply
      0
      • L Lost User

        I have a basic MFC app. Basically, you can start the MFC appwizard, choose Dialog Based, and arrive at a dialog. Now, I want the dialog to monitor they keys pressed on the keyboard (some keys in combination), so I use GetKeyboardState(). The problem is whenever I hit a key it dings. I've attempted to override the WM_KEYDOWN, CHAR and other relative messages. Furthermore, I seem to fail to set the focus away from the OK button by using SetFocus() in the OnInitDialog(). When I remove ALL the controls, the dialog finally gets my WM_KEYDOWN events. I should be able to set the dialog to receive events even with controls on it shouldn't I? But I digress. The only reason why I'm attempting to override those events is because of the dinging. My goal is to make an app in MFC where I can use the keyboard to modify a state structure via quake-like key bindings. I think once I fix the dinging, I'll be happy. Thanks in Adavance

        W Offline
        W Offline
        WoR
        wrote on last edited by
        #3

        The OK button by standard is the default button. You might want to change that too. Wolfgang Reichl

        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