I am facing a problem in setting the tab order in a dialog box. To set the tab order I have used the function SetWindowPos().
Initially it will be focused to one of the dialog item, but if I press tab it will not change the focus to the other items on the dialog box.
Please help he to fix the problem. bellow is the code...
HWND hBtn1 = GetDlgItem(hWnd, IDC_BTN_OPEN);
HWND hBtn2 = GetDlgItem(hWnd, IDC_BTN_CLOSE);
HWND hBtn3 = GetDlgItem(hWnd, IDC_BTN_SAVE);
bool result = ::SetWindowPos(hBtn1, hBtn2, 0, 0, 0, 0,SWP_NOSIZE|SWP_NOMOVE);
result = ::SetWindowPos(hBtn2, hBtn3, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
Do you really have to set the tab order by code? Just press Ctrl+D in the dialog designer!
Update: Using
SetWindowPos
won't help you. The parameter that you think it will define the taborder just sets the z-order, meaning the order how controls are painted if they overlap. I'm not sure, but I think the tab-order is defined by the order how the controls are created.Next update: A possible workaround is to watch the keyboard-events for the Tab-key, then get the active control and set the focus to the control which should come next.