Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


how to define Tab order for CEdit controls in client area

Posted on 1999-07-12
Medium Priority
Last Modified: 2013-11-20
I've a bundle of CEdit controls in my client (CView) area, how would I define tab order for these CEdit controls like they do in the dialog box.
Question by:eugeneng
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
  • 2
  • 2
  • 2
  • +1

Expert Comment

ID: 1309758
CView does not support tabbing between controls as in a dialog. You could use CFormView instead. If you create the controls on the fly however the tabbing order is the same as the order in which the controls are created. Otherwise you will have to do all of the tab sequencing youself by handling TAB, SHIFT-TAB, etc in you CView class.

Author Comment

ID: 1309759
so, how should the CEdit do when it get the tab key-down message ? Call KillFocus() ? (I probably will use PretranslateMessage() to trap the WM_KEYDOWN message).

Expert Comment

ID: 1309760
Use the PreTranslateMessage handler in the CView class. You will need to maintain a list of windows ( CList<CWnd*,CWnd*>, whatever ) that are in the correct tab sequence. Whenever you want to change position ( TAB, SHIFT TAB, etc ) get the required CWnd* and SetFocus to it.
If you can use CFormView in anyway it is definatly advisable. You could leave the dialog blank and generate the edit controls in the same way as you do at the moment.
Remember all the ways of tabbing arround controls. ( ie: the cursor keys will navigate arround buttons, etc ).

Really, use CFormView instead of CView. Your just asking for grief otherwise. But remember, any controls you create must be created in their correct tabing order.
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.


Accepted Solution

VCGuru earned 40 total points
ID: 1309761
Actually what you can do is in the PreTranslateMessage of the view you can have a code as below
if(pMsg->message == WM_KEYDOWN && pMsg->wParam == 9)
static UINT x = IDC_EDIT1;
CEdit *pEdit = (CEdit*)GetDlgItem(X);
                if(X == IDC_LAST)//Last control
                { X = IDC_EDIT1;}
            return 1;
return ...//the default

This is assuming that all your controls have increasing ID's ie difference of 1. this is easy to do.
LVL 23

Expert Comment

ID: 1309762
Why is it always the case your answers are nothing but variation of somebody else's comment for that question? And your answer alwas comes after somebody has posted a valid comment..... Like inthis question.. ur answer is nothing but implementation of Bridge's comment.

No offense :....
Just curious cause i have noticed at lot many places where u have posted answers?

Expert Comment

ID: 1309763
well Naveenkohli,
I know where you get your answers too!! I've seen a lot of your answers. Nothing's original.
No offence intended
LVL 23

Expert Comment

ID: 1309764
Ofcourse VCGuru, these answers come from the books, knowledgebase articles, and MFC source code ...... i don't like spending time on issues which already been discussed or published....
The original ideas i post on codeguru ... not here :))

I am glad that you have time to search where i get answers from :))) Happy searching...

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

721 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