Is it possible to center the new-style common item file dialog on Windows and still maintain the new style?
Calling FileDialog::Center() or FileDialog::CenterOnParent() reverts the style of the dialog to the older-style common control dialog instead of the newer common item dialog. This is because calling either of these methods set the m_bMovedWindow flag. This leads to a hook proc being created to handle the centering after the dialog is initialized.
wxFileDialog::ShowModal() has this code:
if (m_bMovedWindow || HasExtraControlCreator()) // we need these flags.
{
ChangeExceptionPolicy();
msw_flags |= OFN_EXPLORER |OFN_ENABLEHOOK;
msw_flags |= OFN_ENABLESIZING;
}
The problem line is:
msw_flags |= OFN_EXPLORER|OFN_ENABLEHOOK;
Anytime OFN_EXPLORER and OFN_ENABLEHOOK are specified together, Windows reverts to the common control version. This is the best explanation of why that I've found.
If I don't call Center() / CenterOnParent() then I get the new common item dialogs, but they are displayed at the top-left corner of my parent window. This isn't how the rest of my dialogs behave, but the behavior does seem consistent with the behavior of Visual Studio, MS Word, Excel, Firefox, Chrome, and other apps.
I assume that if they don't center the new dialogs then there's not a way to do it. Am I correct?