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. Managed C++/CLI
  4. KeyDown problem

KeyDown problem

Scheduled Pinned Locked Moved Managed C++/CLI
helpdebugging
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.
  • Y Offline
    Y Offline
    yuvald
    wrote on last edited by
    #1

    I have a form (name MyForm), where I want to know when the Arrow keys pressed so I made this function but its not working for the arrow keys. Its working great for all the others (shift, alt, caplock.....) dont know what to do please help in the constructor: this->add_KeyDown(new KeyEventHandler(this, &MyForm::KeyDown)); the function: void MyForm::KeyDown(Object *sender, KeyEventArgs *e) { switch(e->KeyCode) { case Keys::Down: MessageBox::Show("Key Down was pressed"); s->Down(picGame->Handle); } } I tried to step with the debugger, nothing happens when I press arrow keys Its not getting in to the function for all other keys it does.:confused:

    A 1 Reply Last reply
    0
    • Y yuvald

      I have a form (name MyForm), where I want to know when the Arrow keys pressed so I made this function but its not working for the arrow keys. Its working great for all the others (shift, alt, caplock.....) dont know what to do please help in the constructor: this->add_KeyDown(new KeyEventHandler(this, &MyForm::KeyDown)); the function: void MyForm::KeyDown(Object *sender, KeyEventArgs *e) { switch(e->KeyCode) { case Keys::Down: MessageBox::Show("Key Down was pressed"); s->Down(picGame->Handle); } } I tried to step with the debugger, nothing happens when I press arrow keys Its not getting in to the function for all other keys it does.:confused:

      A Offline
      A Offline
      AnsGe
      wrote on last edited by
      #2

      Hai, I just copied your code and its works!!!! Sometimes the focus is not on your Form .

      Y 1 Reply Last reply
      0
      • A AnsGe

        Hai, I just copied your code and its works!!!! Sometimes the focus is not on your Form .

        Y Offline
        Y Offline
        yuvald
        wrote on last edited by
        #3

        Youre right. I tried it with an empty form and it worked. I have on my form only a picturebox and a button, how can I keep the forms focus always. I never need the focus on the other controls. thanks.

        A 1 Reply Last reply
        0
        • Y yuvald

          Youre right. I tried it with an empty form and it worked. I have on my form only a picturebox and a button, how can I keep the forms focus always. I never need the focus on the other controls. thanks.

          A Offline
          A Offline
          AnsGe
          wrote on last edited by
          #4

          hai, Sorry i dont know how it solve!!! Some where i found to override the ProcessmdKey method but i didn't get too much ideas If u solve the problem plz post it by ANish

          Y 1 Reply Last reply
          0
          • A AnsGe

            hai, Sorry i dont know how it solve!!! Some where i found to override the ProcessmdKey method but i didn't get too much ideas If u solve the problem plz post it by ANish

            Y Offline
            Y Offline
            yuvald
            wrote on last edited by
            #5

            Thanks:) I will post if there will be any soloution. Yuval

            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