https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b8c4d589b1e49c78dcafe…
commit b8c4d589b1e49c78dcafefb2252345632b6d0c6f
Author: Jose Carlos Jesus <zecarlos1957(a)hotmail.com>
AuthorDate: Tue Mar 14 18:27:14 2023 -0300
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Mar 14 22:27:14 2023 +0100
[SHELL32] Give opportunity to rename file/folder on its creation (#5139)
* [SHELL32] Fix issue when creating a new file or folder. No chance to rename the
displayed name.
The CNewMenu::SelectNewItem method starts with a request to notify the View object
about a new item by calling SHChangeNotify.
After creating and obtaining the new PIDL by calling ILFindLastID, the
CDefView::SelectItem method is called.
This method fails right from the start when calling LV_FindItemByPidl which returns
-1, thus preventing the user from being given the opportunity to change the name displayed
by default.
This failure is due to the fact that this object has not yet been added to the
CDefView::m_ListView list. This is caused by the asynchronous nature of SHChangeNotify.
Thanks to Giannis Adamopoulos for the big help.
---
dll/win32/shell32/CDefView.cpp | 1 -
dll/win32/shell32/CDefaultContextMenu.cpp | 2 +-
dll/win32/shell32/CNewMenu.cpp | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp
index 6b51d9e83cd..7cf9160df58 100644
--- a/dll/win32/shell32/CDefView.cpp
+++ b/dll/win32/shell32/CDefView.cpp
@@ -990,7 +990,6 @@ BOOLEAN CDefView::LV_ProdItem(PCUITEMID_CHILD pidl)
lvItem.iImage = SHMapPIDLToSystemImageListIndex(m_pSFParent, pidl, 0);
m_ListView.SetItem(&lvItem);
m_ListView.Update(nItem);
- m_ListView.EditLabel(nItem);
return TRUE;
}
diff --git a/dll/win32/shell32/CDefaultContextMenu.cpp
b/dll/win32/shell32/CDefaultContextMenu.cpp
index 2559e6e0438..577e93d332e 100644
--- a/dll/win32/shell32/CDefaultContextMenu.cpp
+++ b/dll/win32/shell32/CDefaultContextMenu.cpp
@@ -926,7 +926,7 @@ CDefaultContextMenu::DoCreateNewFolder(
CComPtr<IShellView> psv;
/* Notify the view object about the new item */
- SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, (LPCVOID)wszName, NULL);
+ SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW | SHCNF_FLUSH, (LPCVOID)wszName, NULL);
if (!m_site)
return S_OK;
diff --git a/dll/win32/shell32/CNewMenu.cpp b/dll/win32/shell32/CNewMenu.cpp
index f3ec59cf3da..a02314b1d8e 100644
--- a/dll/win32/shell32/CNewMenu.cpp
+++ b/dll/win32/shell32/CNewMenu.cpp
@@ -418,7 +418,7 @@ HRESULT CNewMenu::SelectNewItem(LONG wEventId, UINT uFlags, LPWSTR
pszName, BOOL
dwSelectFlags |= SVSI_EDIT;
/* Notify the view object about the new item */
- SHChangeNotify(wEventId, uFlags, (LPCVOID) pszName, NULL);
+ SHChangeNotify(wEventId, uFlags | SHCNF_FLUSH, (LPCVOID)pszName, NULL);
if (!m_pSite)
return S_OK;