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 / C++ / MFC
  4. Navigating through CForimView controls

Navigating through CForimView controls

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 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.
  • D Offline
    D Offline
    dart13
    wrote on last edited by
    #1

    How to implement movement between button controls placed on a CFormView with arrow keys? Buttons are positioned like chessboard squares - so when the arrow key for left is pressed the focus should move to the button placed left and so on. Should SetFocus() be overriden?

    J 1 Reply Last reply
    0
    • D dart13

      How to implement movement between button controls placed on a CFormView with arrow keys? Buttons are positioned like chessboard squares - so when the arrow key for left is pressed the focus should move to the button placed left and so on. Should SetFocus() be overriden?

      J Offline
      J Offline
      Johan Rosengren
      wrote on last edited by
      #2

      I have difficulties seeing what SetFocus should accomplish :) You can, for example, add the arrow keys as accelerators in the accelerator table and map them to functions in your view.

      D 1 Reply Last reply
      0
      • J Johan Rosengren

        I have difficulties seeing what SetFocus should accomplish :) You can, for example, add the arrow keys as accelerators in the accelerator table and map them to functions in your view.

        D Offline
        D Offline
        dart13
        wrote on last edited by
        #3

        I just want to move focus from one button to another, so the desired button can be activated by pressing ENTER. It is possible to move focus with TAB key as well as with arrow keys, but focus goes from one button to the other as it was set in Layout -> Tab Order. What I want to accomplish is to move focus in one of four directions using arrow keys, but I am not sure what's the best way to implement this behaviour.

        J 1 Reply Last reply
        0
        • D dart13

          I just want to move focus from one button to another, so the desired button can be activated by pressing ENTER. It is possible to move focus with TAB key as well as with arrow keys, but focus goes from one button to the other as it was set in Layout -> Tab Order. What I want to accomplish is to move focus in one of four directions using arrow keys, but I am not sure what's the best way to implement this behaviour.

          J Offline
          J Offline
          Johan Rosengren
          wrote on last edited by
          #4

          dart13 wrote: What I want to accomplish is to move focus in one of four directions using arrow keys I understood that much, and I really think that you should try with accelerators. In the view - where you handle the message - you might want to check what control currently has the focus, and change it according to the pattern you want. It is a button having the focus when the key is pressed, and therefore the keypress will be sent to the button (actually, the key up message will be sent... to the button the focus was moved to!). Therefore, the most basic place to handle this would be in a CButton-derived class. But it is not a good way to solve the problem! If you try handling the focus setting itself, you'll get into all sorts of grief, as changing the focus in a focus-handler (that is, a handler to WM_SETFOCUS) will most probably get you in trouble. Furthermore, if you handle this from the buttons themselves, you'll have to post messages to the owner anyway, as an individual button will have no knowledge of the other buttons on the view. So, accelerators!

          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