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. Tab navigation problem

Tab navigation problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
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.
  • S Offline
    S Offline
    skaanji
    wrote on last edited by
    #1

    I create modelles dialog box as child inside a window (not using MFC) tab navigation between controls does not work :wtf: is there some way to implement it ? Thanks.

    K 1 Reply Last reply
    0
    • S skaanji

      I create modelles dialog box as child inside a window (not using MFC) tab navigation between controls does not work :wtf: is there some way to implement it ? Thanks.

      K Offline
      K Offline
      KaRl
      wrote on last edited by
      #2

      I had the problem with a modeless dialog owned by an ActiveX main window. Using MFC, I solved this by implementing in the PreTranslateMessage method of the Main Window the following code: if((pMsg->message == WM_KEYDOWN) && (::IsWindow(pMsg->hwnd))){ HWND hMsgWnd = pMsg->hwnd; HWND hParent = ::GetParent(hMsgWnd); // Specific for modeless dialogs if(hParent){ if((pMsg->wParam == VK_TAB) || (pMsg->wParam == VK_RETURN)){ if(CWnd::FromHandle(hMsgWnd)->PreTranslateMessage(pMsg)) return TRUE; else if(pMsg->wParam == VK_TAB){ // Activate next or previous tabbed control, according to Shift value BOOL bShift = HIBYTE(GetKeyState(VK_SHIFT)); HWND hNewWnd = ::GetNextDlgTabItem(hParent, hMsgWnd, bShift); if(hNewWnd){ TCHAR szClass[10]; HWND hFirstWnd = hNewWnd; BOOL bBreak = FALSE; // if it's a static, do it again while(::GetClassName(hNewWnd, szClass, 10) && (lstrcmpi(szClass, _T("STATIC")) == 0)){ HWND hOldWnd = hNewWnd; hNewWnd = ::GetNextDlgTabItem(hParent, hNewWnd, bShift); if(hNewWnd == hOldWnd){ hNewWnd = NULL; break; } if(bBreak){ hNewWnd = NULL; break; } bBreak = (hNewWnd == hFirstWnd); } if(hNewWnd){ ::SetFocus(hNewWnd); return TRUE; } } }else{ if(pMsg->wParam == VK_RETURN){ TCHAR szClass[10]; if(::GetClassName(hMsgWnd, szClass, 10) && (lstrcmpi(szClass, _T("BUTTON")) == 0)){ ::SendMessage(hParent, WM_COMMAND, ::GetDlgCtrlID(hMsgWnd), (LPARAM)hMsgWnd); return TRUE; } } } return CWnd::FromHandle(hParent)->PreTranslateMessage(pMsg); } if(CWnd::FromHandle(hParent)->PreTranslateMessage(pMsg)) return TRUE; } }


      We do not inherit the Earth from our ancestors, we borrow it from our children - Antoine de Saint-Exupéry (1900-1944)

      S 1 Reply Last reply
      0
      • K KaRl

        I had the problem with a modeless dialog owned by an ActiveX main window. Using MFC, I solved this by implementing in the PreTranslateMessage method of the Main Window the following code: if((pMsg->message == WM_KEYDOWN) && (::IsWindow(pMsg->hwnd))){ HWND hMsgWnd = pMsg->hwnd; HWND hParent = ::GetParent(hMsgWnd); // Specific for modeless dialogs if(hParent){ if((pMsg->wParam == VK_TAB) || (pMsg->wParam == VK_RETURN)){ if(CWnd::FromHandle(hMsgWnd)->PreTranslateMessage(pMsg)) return TRUE; else if(pMsg->wParam == VK_TAB){ // Activate next or previous tabbed control, according to Shift value BOOL bShift = HIBYTE(GetKeyState(VK_SHIFT)); HWND hNewWnd = ::GetNextDlgTabItem(hParent, hMsgWnd, bShift); if(hNewWnd){ TCHAR szClass[10]; HWND hFirstWnd = hNewWnd; BOOL bBreak = FALSE; // if it's a static, do it again while(::GetClassName(hNewWnd, szClass, 10) && (lstrcmpi(szClass, _T("STATIC")) == 0)){ HWND hOldWnd = hNewWnd; hNewWnd = ::GetNextDlgTabItem(hParent, hNewWnd, bShift); if(hNewWnd == hOldWnd){ hNewWnd = NULL; break; } if(bBreak){ hNewWnd = NULL; break; } bBreak = (hNewWnd == hFirstWnd); } if(hNewWnd){ ::SetFocus(hNewWnd); return TRUE; } } }else{ if(pMsg->wParam == VK_RETURN){ TCHAR szClass[10]; if(::GetClassName(hMsgWnd, szClass, 10) && (lstrcmpi(szClass, _T("BUTTON")) == 0)){ ::SendMessage(hParent, WM_COMMAND, ::GetDlgCtrlID(hMsgWnd), (LPARAM)hMsgWnd); return TRUE; } } } return CWnd::FromHandle(hParent)->PreTranslateMessage(pMsg); } if(CWnd::FromHandle(hParent)->PreTranslateMessage(pMsg)) return TRUE; } }


        We do not inherit the Earth from our ancestors, we borrow it from our children - Antoine de Saint-Exupéry (1900-1944)

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

        Thanks!!!

        K 1 Reply Last reply
        0
        • S skaanji

          Thanks!!!

          K Offline
          K Offline
          KaRl
          wrote on last edited by
          #4

          My pleasure :)


          We do not inherit the Earth from our ancestors, we borrow it from our children - Antoine de Saint-Exupéry (1900-1944)

          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