Search code examples
winapitabswindows-10tabindex

How can I set the control's tab index?


Does winapi supports something like Control.TabIndex? if not, how is this usually implemented? Do I have to process the key tab press from a WM_KEYDOWN message and set focus on the control accordingly or is there something native to do that? I have no code to show yet because I'm trying to figure out how begun to do that.


Solution

  • Tab order is based o z-order (order in which children are painted). Initially z-order is based on creation order, so controls are painted and tabbed in same order as creation order.

    When creating controls this could be changed by reordering creation sequence (in code or *.rc file).

    After creation use SetWindowPos( hwnd, other_hwnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); to rearrange controls in z-order.