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. Any way to stop menu strip from 'capturing' alt-key?

Any way to stop menu strip from 'capturing' alt-key?

Scheduled Pinned Locked Moved Windows Forms
databasequestion
4 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.
  • S Offline
    S Offline
    sri_0099
    wrote on last edited by
    #1

    Hi All, I have a Win Form on which I use the KeyDown event to perform certain activities using Alt-Key combinations. Unfortunately, this also triggers the menustrip 'capturing' the Alt key and highlighting the default menu item ('File') and essentially disabling any further typing until the Alt key is pressed again. Is there any way to stop the file menu from capturing the Alt when this is used to trigger operations in the KeyDown event? Thanks, Sri

    D 1 Reply Last reply
    0
    • S sri_0099

      Hi All, I have a Win Form on which I use the KeyDown event to perform certain activities using Alt-Key combinations. Unfortunately, this also triggers the menustrip 'capturing' the Alt key and highlighting the default menu item ('File') and essentially disabling any further typing until the Alt key is pressed again. Is there any way to stop the file menu from capturing the Alt when this is used to trigger operations in the KeyDown event? Thanks, Sri

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

      How are you checking if Alt key was pressed? Instead of e.KeyCode == Keys.Alt, use e.Alt.

      It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

      S 1 Reply Last reply
      0
      • D dan sh

        How are you checking if Alt key was pressed? Instead of e.KeyCode == Keys.Alt, use e.Alt.

        It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

        S Offline
        S Offline
        sri_0099
        wrote on last edited by
        #3

        Hi, Thanks for your reply.Unfortunately, i did not write single piece of code to check which key was pressed. In form i have added button text like (&Help...etc). my menustrip still captures the alt key(First time), and still disables any further typing until I press alt again. I'm using key combinations of Alt-A, Alt-D etc to focus onto various fields on the form. Any of these will force the menustrip to capture the Alt key. Regards, Sri

        L 1 Reply Last reply
        0
        • S sri_0099

          Hi, Thanks for your reply.Unfortunately, i did not write single piece of code to check which key was pressed. In form i have added button text like (&Help...etc). my menustrip still captures the alt key(First time), and still disables any further typing until I press alt again. I'm using key combinations of Alt-A, Alt-D etc to focus onto various fields on the form. Any of these will force the menustrip to capture the Alt key. Regards, Sri

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Your key-combinations (where Alt and A are both pressed at the same time) work, even if a single keypress on the Alt prevents further input. A keypress on Alt should give you the option to browse the menu. Windows doesn't capture the key, but the focus. The second keystroke then determines what menu to open. That's two seperate keystrokes. Your key-combination is Alt-A, and the A is typed while the Alt-key is down. That gives different behaviour on Windows - it first checks if there's a shortcut-key defined (e.g., the letter right after the "&"-char in the caption of a button) These two behaviors shouldn't bite each other. If your end-user is like me, he'll be using the Alt-key often enough to navigate the menu :)

          I are Troll :)

          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