tags:

views:

22

answers:

1

Hi,

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);
+1  A: 

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.

dwo
no i want set it Programatically.
Umesha MS
i searched in the net to set the tab order but most of them told to use SetWindowPos(). i their any way to set the tab order Programatically.
Umesha MS
IsDialogMessage implements tabbing. Its logic is to call hwnd = GetWindow( hwnd, GW_NEXT ); starting with the current focus control HWND in a loop until it finds a child window with the WS_TABSTOP style.
Chris Becke
But I think that the call to GetWindow(hwnd,GW_NEXT) is the same as NextDlgCtrl() and you can't change the tab-order at runtime.
dwo