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

x
?
Solved

Dynamic tab order change

Posted on 1997-05-30
4
Medium Priority
?
246 Views
Last Modified: 2013-11-20
I have a dialog class - CPasswdDlg - which I want to use to service two similar user requests.
The dialog class has two edit controls plus OK and Cancel button controls. The current tab order now is: first edit control (call it X), OK, Cancel, second edit control (call it Y).
This is OK for one type of user requests, as Y edit control is filled in by the application (X edit control must _always_ be filled in by the user) and its content rarely needs to be changed by the user (hence it is at the end of tab order).
However, for other type of user request, user must himself supply the data in the Y edit control. If the tab order remains the same, user must cycle through OK and Cancel controls before coming to the Y edit control - clearly unacceptable.
What I want is to change tab order dynamically. For first type of user request when Y is filled in by application, tab order should be  X, OK, Cancel, Y. For second type of user request when Y too is filled in by user, tab order should be Y, X, OK, Cancel - i.e. Y should go from end of tab order to the beginning of tab order.
I tried to do this in DoDataExchange and in OnInitDialog:

DoDataExchange(pDX)
{
    //(Class Wizard stuff)
   :
   if(pDX->m_bSaveAndValidate == FALSE)
   {
      // Standard order: X, OK, Cancel, Y
      // To get Y, X, OK, Cancel, all that is required is to set primary
      // focus on Y
      GetDlgItem(IDC_EDIT_Y)->SetFocus()
   }
   else
   {
      // Standard X, OK, Cancel, Y order. All that is required to
      // get at this order is to set primary focus on X
      GetDlgItem(IDC_EDIT_X)->SetFocus()
   }
}

It doesn't work. I've tried also using GotoDlgCtrl(GetDlgItem(IDC_EDIT_Y)) instead of the first command in the example, still useless. I tried this in DoDataExchange, OnInitDialog and OnCreate and am running out of ideas.
I don't want to use MoveWindow to switch positions on the screen between X and Y as this would not give proper effect - tab order would still be X, OK, Cancel, Y, so focus would move from X (now in place where Y was) to OK and Cancel to Y(now in place where X was).
0
Comment
Question by:pb1
[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
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
AVaulin earned 280 total points
ID: 1301892
You said "for one request, one control must be the first in tab order, while for another request, another control must be first". I don't know what do you mean. But here some propositions:
- you may use SetFocus() to request control in DoDataExchange method of dialog class (when pDX->m_bSaveAndValidate == FALSE);
-) or you may change control placement by using GetWindowRect and MoveWindow methods (again in DoDataExchange).
Or try to give more comments.
0
 

Author Comment

by:pb1
ID: 1301893
Edited text of question
0
 

Author Comment

by:pb1
ID: 1301894
I've edited question completely, hope it is clearer now what I want to do.
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301895
I found your problem solving. Add BOOL bFirstPaint member to your dialog class and init it by TRUE in constructor. Handle WM_PAINT message and add next fragmnet to handler:

if( flFirstPaint )
{
 if( /*second request */ ) PrevDlgCtrl();
 flFirstPaint = FALSE;
}

I hope this help.
0

Featured Post

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.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 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