Solved

Tab stops no longer work

Posted on 2003-11-26
7
405 Views
Last Modified: 2013-11-20
I switched from a CFormView to a CScrollView as a base class for my view in an SDI app. The switch helped me with some things, but it caused the tab stops for my controls (edits) to no longer work. Can someone tell me a way to get the tab stops back? (I'm using Visual C++ 6 SP5)
0
Comment
Question by:Particleness
  • 4
  • 2
7 Comments
 
LVL 12

Accepted Solution

by:
migel earned 200 total points
ID: 9827418
Hi!
You need to override PreTranslateMessage in the your view view:

BOOL CMyView::PreTranslateMessage(MSG* pMsg)
{
      ASSERT(pMsg != NULL);
      ASSERT_VALID(this);
      ASSERT(m_hWnd != NULL);

      // allow tooltip messages to be filtered
      if (CScrollView::PreTranslateMessage(pMsg))
            return TRUE;

      // don't translate dialog messages when in Shift+F1 help mode
      CFrameWnd* pFrameWnd = GetTopLevelFrame();
      if (pFrameWnd != NULL && pFrameWnd->m_bHelpMode)
            return FALSE;

      // since 'IsDialogMessage' will eat frame window accelerators,
      //   we call all frame windows' PreTranslateMessage first
      pFrameWnd = GetParentFrame();   // start with first parent frame
      while (pFrameWnd != NULL)
      {
            // allow owner & frames to translate before IsDialogMessage does
            if (pFrameWnd->PreTranslateMessage(pMsg))
                  return TRUE;

            // try parent frames until there are no parent frames
            pFrameWnd = pFrameWnd->GetParentFrame();
      }

      // don't call IsDialogMessage if form is empty
      if (::GetWindow(m_hWnd, GW_CHILD) == NULL)
            return FALSE;

      // filter both messages to dialog and from children
      return PreTranslateInput(pMsg);
}
0
 

Author Comment

by:Particleness
ID: 9827455
The code looks great, but the tab doesn't wrap around back to the beginning. How can I get it to wrap around?
0
 

Author Comment

by:Particleness
ID: 9827501
Actually, I think the tabs are getting stuck on a rich edit control instead of not wrapping around.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Particleness
ID: 9827897
The code works for normal edit controls but not for rich edit controls. Can an expert help me tab rich edit controls?
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 150 total points
ID: 9830053
Do you really want to stop the user putting a tab into a RichEdit (stop part of formatting)?  

Override PreTranslateMessage in your view.
BOOL CMyView::PreTranslateMessage(MSG* pMsg)
{
    if(pMsg->message == WM_KEYDOWN)
      {
            long nID = ::GetDlgCtrlID(pMsg->hwnd);
            if((pMsg->wParam == VK_TAB) && (nID == IDC_MY_RICH_EDIT))

now put in the behaviour you want eg. NextDlgCtrl() then return TRUE to show the system you have handled the message
0
 
LVL 12

Expert Comment

by:migel
ID: 9830074
Also you must handle SHIFT+TAB keystroke to move focus to the previous control.
0
 

Author Comment

by:Particleness
ID: 9832857
Wow, that was fast and precise..I'm upping the points by 100 for you two.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 127
set up trigger (or something) to rename files (starting with ATL) in a linux directory 6 55
Define unique primary key 9 95
sumHeights  challenge 17 75
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question