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. How to change focus from TreeView to ListView using tab in MFC?

How to change focus from TreeView to ListView using tab in MFC?

Scheduled Pinned Locked Moved C / C++ / MFC
c++windows-adminhelptutorialquestion
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
    yvanc
    wrote on last edited by
    #1

    Hello, I am currently working on an MFC project. The project have a treeview and listview similar to the layout of windows registry editor. I was just wondering if any of you guys know how to change the focus wherein if the user click one item in the treeview and then presses the tab key the focus would be changed to the corresponding item in the listview? Please help.

    E 1 Reply Last reply
    0
    • Y yvanc

      Hello, I am currently working on an MFC project. The project have a treeview and listview similar to the layout of windows registry editor. I was just wondering if any of you guys know how to change the focus wherein if the user click one item in the treeview and then presses the tab key the focus would be changed to the corresponding item in the listview? Please help.

      E Offline
      E Offline
      Eugen Podsypalnikov
      wrote on last edited by
      #2

      Try it :) :

      /*virtual*/ BOOL CLeft(Right)View::PreTranslateMessage(MSG* pMsg)
      {
      if (WM_KEYDOWN == pMsg->message) {
      if (VK_TAB == pMsg->wParam) {
      CWnd* pcWnd = YourFunctionToGetRight(Left)View();
      if (pcWnd) {
      pcWnd->SetFocus(); // :)
      }
      return TRUE;
      }
      }
      return CBaseOfLeft(Right)View::PreTranslateMessage(MSG* pMsg);
      }

      virtual void BeHappy() = 0;

      Y 1 Reply Last reply
      0
      • E Eugen Podsypalnikov

        Try it :) :

        /*virtual*/ BOOL CLeft(Right)View::PreTranslateMessage(MSG* pMsg)
        {
        if (WM_KEYDOWN == pMsg->message) {
        if (VK_TAB == pMsg->wParam) {
        CWnd* pcWnd = YourFunctionToGetRight(Left)View();
        if (pcWnd) {
        pcWnd->SetFocus(); // :)
        }
        return TRUE;
        }
        }
        return CBaseOfLeft(Right)View::PreTranslateMessage(MSG* pMsg);
        }

        virtual void BeHappy() = 0;

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

        I have tried the code above but it slows down the application to the point it no longer populates the treeview, is there any other alternative?

        E 1 Reply Last reply
        0
        • Y yvanc

          I have tried the code above but it slows down the application to the point it no longer populates the treeview, is there any other alternative?

          E Offline
          E Offline
          Eugen Podsypalnikov
          wrote on last edited by
          #4

          Of course, try to implement the reactions on WM_KEYDOWN for the both views :)

          virtual void BeHappy() = 0;

          Y 1 Reply Last reply
          0
          • E Eugen Podsypalnikov

            Of course, try to implement the reactions on WM_KEYDOWN for the both views :)

            virtual void BeHappy() = 0;

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

            thanks a lot, it works now.

            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