To change tab order at run-time you can use SetWindowPos function. Assume we have some control with id IDC_STATIC and another one, which was created dynamically (IDC_DYNAMIC). We need set dynamic control the next after IDC_STATIC. It can be done with like the following:
HWND hNext = ::GetNextWindow(GetDlgItem(IDC_STATIC)->GetSafeHwnd(), GW_HWNDNEXT); ::SetWindowPos(GetDlgItem(IDC_DYNAMIC)->GetSafeHwnd(), GetDlgItem(IDC_STATIC)->GetSafeHwnd(), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE ); ::SetWindowPos(hNext, GetDlgItem(IDC_DYNAMIC)->GetSafeHwnd(), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE );
But if you want add child dialog to your form the method above doesn't work. Tab sequences of the parent and child window will be independent. The easiest way in such case is to add the following line in the child dialog implementation class after child dialog creation:
ModifyStyleEx(0, WS_EX_CONTROLPARENT);
No comments:
Post a Comment