Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Tab stops no longer work

Posted on 2003-11-26
7
Medium Priority
?
409 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 800 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 45

Assisted Solution

by:AndyAinscow
AndyAinscow earned 600 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

609 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