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:
//(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
// Standard X, OK, Cancel, Y order. All that is required to
// get at this order is to set primary focus on X
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).