Question

Often time I need to add a control to a dialog after the dialog has been generated via dialog template and CreateDialogIndirect. In these cases the tab order is set by the dialog template and there is no obvious way to change the tab order by including a newly created control.

Was it helpful?

Solution

I recently discovered that you can use SetWindowPos to accomplish this. Determine which control after which you want to insert the new control in the tab order then use SetWindowPos like this:

SetWindowPos(hNewControl, hOldControl, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); 

This changes the z-order of controls which, in turn, establishes the tab order.

OTHER TIPS

I know this is an old question but here is how to do it at compile time (which is preferable in the vast majority of cases): http://msdn.microsoft.com/en-us/library/7039hzb0(v=vs.80).aspx

My favourite method:

  1. From the View menu, choose Tab Order.
  2. Choose Assign Interactively.
  3. Double-click the tab order box beside the control you want to be the first control in the tab order.
  4. Click the tab order box for each of the other controls.
  5. Click anywhere on the form to save your changes and exit Tab Order mode, or press ESC to exit Tab Order mode without saving your changes.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top