More manual merging of Win32 changes

This manually merges the changes that @monkeyiq and I did. There were also some leftover naming conflicts over PrintDlg.

Not to be merged yet, because my compile on Windows hasn't finished yet.