Solved

Tab stops no longer work

Posted on 2003-11-26
7
400 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now