Solved

Tab stops no longer work

Posted on 2003-11-26
7
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

724 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