The code for making modeless dialogs would work for modeless. But modal dialogs have a lot of specialized code for getting values, putting those values in the right places, etc. This is vital for a modeless dialog, but not for a modal one.
Instead, what we can do is pass a modal dialog a Lua table. The keys in the table are ids of controls, and the values represent the initial state/data of those controls. When the dialog is closed, the values of the struct are set to the values entered.
This would also make it possible to have range controls and such.
If you don't pass a table, it simply initializes all of the fields with nothing, and passes back a table of control ids and data.