Solved

Tab stops no longer work

Posted on 2003-11-26
7
404 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 37
dog bark java program 15 95
pre4 challenge 19 100
zeroFront challenge 7 99
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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