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
  • 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.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.


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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Suggested Courses

597 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