Fix file doesn't save as extension type on Windows 7

Initialize file dialog window procedures later so that
all the controls have been created by this moment.

Fix #9657, close #9674
This commit is contained in:
mere-human 2021-03-19 22:19:32 +02:00 committed by Don HO
parent 805ff42cd4
commit ad3a6ea2f6
1 changed files with 7 additions and 6 deletions

View File

@ -250,11 +250,9 @@ public:
{
return S_OK;
}
IFACEMETHODIMP OnFolderChange(IFileDialog* dlg) override
IFACEMETHODIMP OnFolderChange(IFileDialog*) override
{
// First launch order: 3. Custom controls are added but inactive.
if (!_dialog)
initDialog(dlg);
return S_OK;
}
IFACEMETHODIMP OnFolderChanging(IFileDialog*, IShellItem*) override
@ -262,9 +260,11 @@ public:
// First launch order: 2. Buttons are added, correct window title.
return S_OK;
}
IFACEMETHODIMP OnSelectionChange(IFileDialog*) override
IFACEMETHODIMP OnSelectionChange(IFileDialog* dlg) override
{
// First launch order: 4. Main window is shown.
if (!_dialog)
initDialog(dlg);
return S_OK;
}
IFACEMETHODIMP OnShareViolation(IFileDialog*, IShellItem*, FDE_SHAREVIOLATION_RESPONSE*) override
@ -300,6 +300,8 @@ private:
FileDialogEventHandler(FileDialogEventHandler&&) = delete;
FileDialogEventHandler& operator=(FileDialogEventHandler&&) = delete;
// Inits dialog pointer and overrides window procedures for file name edit and ok button.
// Call this as late as possible to ensure all the controls of the dialog are created.
void initDialog(IFileDialog * d)
{
assert(!_dialog);
@ -347,9 +349,8 @@ private:
return fileName;
}
// Modifies the file name if necesary after user confirmed input.
// Called after the user input but before OnFileOk() and before any name validation.
// Prefer SendMessage communication with the edit box here rather than IFileDialog methods.
// The setter methods post the message to the queue, and it may not be processed in time.
void onPreFileOk()
{
if (!_dialog)