Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you programmatically change the tab order in a Win32 dialog?

Tags:

dialog

winapi

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.

like image 908
Karim Avatar asked Sep 08 '08 17:09

Karim


1 Answers

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.

like image 58
Karim Avatar answered Sep 19 '22 05:09

Karim