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. Windows Forms
  4. Discarding Keyboard-Events for GUI

Discarding Keyboard-Events for GUI

Scheduled Pinned Locked Moved Windows Forms
javascripthelpquestion
5 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.
  • J Offline
    J Offline
    J Holzer
    wrote on last edited by
    #1

    Hi! I have an application that has a keyboard-listener (system-hook). It is being notified on any keyboad-event, even if the app-windows is not active. As far as that it works as designed. My problem is, that it is possible, that someone pushed the space-bar or the cursor-buttons, what effects on the GUI, e.g. to buttons, list-views, etc... So if someone presses the curser-buttons a highlight wanders around my gui. And if the spacebar is hit and a button was highlighted this button will be pressed. This is what i´d like to avoid. What i´d like to have is to make the gui ignore these keyboard inputs (except textboxes, where you need the keyboard). Is there a way of making the GUI-elements not react on keyboard-actions? Thanx J.

    D 1 Reply Last reply
    0
    • J J Holzer

      Hi! I have an application that has a keyboard-listener (system-hook). It is being notified on any keyboad-event, even if the app-windows is not active. As far as that it works as designed. My problem is, that it is possible, that someone pushed the space-bar or the cursor-buttons, what effects on the GUI, e.g. to buttons, list-views, etc... So if someone presses the curser-buttons a highlight wanders around my gui. And if the spacebar is hit and a button was highlighted this button will be pressed. This is what i´d like to avoid. What i´d like to have is to make the gui ignore these keyboard inputs (except textboxes, where you need the keyboard). Is there a way of making the GUI-elements not react on keyboard-actions? Thanx J.

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Handle the KeyDown event and set SupressKeyPress to True.

      Avoid Google. Use Blackle[^]

      J 1 Reply Last reply
      0
      • D dan sh

        Handle the KeyDown event and set SupressKeyPress to True.

        Avoid Google. Use Blackle[^]

        J Offline
        J Offline
        J Holzer
        wrote on last edited by
        #3

        This didn´t work the way i need it. For testing i just built a small App, containing a form with 9 buttons. I handled the KeyDown-Event and set SupressKeyPress to true, but i still could navigation through my buttons with the cursor-keys and click them using the space-bar. I checked that with handling the Click-event, which behaved exactly like it did without SupressKeyPress set to true. I guess that this keyboard events are handled BEFOR they even arrive at my KeyDown-handler. The question is, if this prior handling can be suppressed in any way...

        D 1 Reply Last reply
        0
        • J J Holzer

          This didn´t work the way i need it. For testing i just built a small App, containing a form with 9 buttons. I handled the KeyDown-Event and set SupressKeyPress to true, but i still could navigation through my buttons with the cursor-keys and click them using the space-bar. I checked that with handling the Click-event, which behaved exactly like it did without SupressKeyPress set to true. I guess that this keyboard events are handled BEFOR they even arrive at my KeyDown-handler. The question is, if this prior handling can be suppressed in any way...

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          I tried the same and found one strange thing. Here it is: I have three buttons and a textbox. On buttons click, button name will be displayed in the textbox. If I put breakpoint at keydown event, click event is not fired. But remove the breakpoint and its fired.:confused: I guess you will need to override WndProc method to achieve your task.

          Avoid Google. Use Blackle[^]

          J 1 Reply Last reply
          0
          • D dan sh

            I tried the same and found one strange thing. Here it is: I have three buttons and a textbox. On buttons click, button name will be displayed in the textbox. If I put breakpoint at keydown event, click event is not fired. But remove the breakpoint and its fired.:confused: I guess you will need to override WndProc method to achieve your task.

            Avoid Google. Use Blackle[^]

            J Offline
            J Offline
            J Holzer
            wrote on last edited by
            #5

            That´s the same thing i experienced. Strange... Thanx anyway!

            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