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#
  4. Handling ALT Key on Controls

Handling ALT Key on Controls

Scheduled Pinned Locked Moved C#
question
6 Posts 4 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.
  • V Offline
    V Offline
    Vertyg0
    wrote on last edited by
    #1

    Hello, I want to create control(s) that would act like MS office 2007, so that when you press ALT key all controls that have hotkey will be repainted with hotkey drawn on itself. I dont want to use KeyDown, KeyPress, KeyUp events. Could it be all done trought some kind of extending of controls or so ? overriding WndProc or so ? Thanks.

    C N A 3 Replies Last reply
    0
    • V Vertyg0

      Hello, I want to create control(s) that would act like MS office 2007, so that when you press ALT key all controls that have hotkey will be repainted with hotkey drawn on itself. I dont want to use KeyDown, KeyPress, KeyUp events. Could it be all done trought some kind of extending of controls or so ? overriding WndProc or so ? Thanks.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You could override the control classes, or you could use CreateGraphics to draw your keys direct to the screen, then call Invalidate in the key up, so the form gets repainted.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      V 1 Reply Last reply
      0
      • C Christian Graus

        You could override the control classes, or you could use CreateGraphics to draw your keys direct to the screen, then call Invalidate in the key up, so the form gets repainted.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        V Offline
        V Offline
        Vertyg0
        wrote on last edited by
        #3

        Chris, Yes I want to paint them on control but how to handle pressing of ALT+KEY ? I dont want to use KeyPress, KeyDown events?

        C 1 Reply Last reply
        0
        • V Vertyg0

          Chris, Yes I want to paint them on control but how to handle pressing of ALT+KEY ? I dont want to use KeyPress, KeyDown events?

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Vertyg0 wrote:

          I dont want to use KeyPress, KeyDown events?

          Why on earth not ? You can use a WndProc to catch these events earlier, but you really have no option but to use them, you want to catch when a key is down, and when it's raised again.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          1 Reply Last reply
          0
          • V Vertyg0

            Hello, I want to create control(s) that would act like MS office 2007, so that when you press ALT key all controls that have hotkey will be repainted with hotkey drawn on itself. I dont want to use KeyDown, KeyPress, KeyUp events. Could it be all done trought some kind of extending of controls or so ? overriding WndProc or so ? Thanks.

            N Offline
            N Offline
            Nader Elshehabi
            wrote on last edited by
            #5

            Hello You can set a property called KeyPreview to truein your form itself. Then handle KeyDown event in the Form level. It will catch any KeyDown events in any control in that form before it is sent to that control.

            Regards:rose:

            1 Reply Last reply
            0
            • V Vertyg0

              Hello, I want to create control(s) that would act like MS office 2007, so that when you press ALT key all controls that have hotkey will be repainted with hotkey drawn on itself. I dont want to use KeyDown, KeyPress, KeyUp events. Could it be all done trought some kind of extending of controls or so ? overriding WndProc or so ? Thanks.

              A Offline
              A Offline
              Andrei Ungureanu
              wrote on last edited by
              #6

              Try adding & in front of the letter that will be the hot key

              Do your best to be the best

              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