mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 12:03:29 +00:00
[REGEDIT] Creating a new Key should add a new entry even when no child exist. CORE-18878 (#5274)
- Avoid using a NULL pointer when My Computer is selected, by disabling the New Key menu item. - Simplifies and fix code style in GetItemPath function. - Add a new entry even when no child items exist. CORE-18878
This commit is contained in:
parent
f870bbe1d4
commit
7f45cac9ab
1 changed files with 21 additions and 9 deletions
|
@ -90,14 +90,25 @@ LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
|
||||||
int pathLen = 0, maxLen;
|
int pathLen = 0, maxLen;
|
||||||
|
|
||||||
*phRootKey = NULL;
|
*phRootKey = NULL;
|
||||||
if (!pathBuffer) pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024);
|
|
||||||
if (!pathBuffer) return NULL;
|
if (!pathBuffer)
|
||||||
*pathBuffer = 0;
|
{
|
||||||
|
pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024);
|
||||||
|
}
|
||||||
|
if (!pathBuffer)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pathBuffer = UNICODE_NULL;
|
||||||
|
|
||||||
maxLen = (int) HeapSize(GetProcessHeap(), 0, pathBuffer);
|
maxLen = (int) HeapSize(GetProcessHeap(), 0, pathBuffer);
|
||||||
if (maxLen == -1) return NULL;
|
|
||||||
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
|
if (!hItem)
|
||||||
if (!hItem) return NULL;
|
{
|
||||||
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen))
|
hItem = TreeView_GetSelection(hwndTV);
|
||||||
|
}
|
||||||
|
if (maxLen == -1 || !hItem || !get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +364,7 @@ HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name)
|
||||||
if (!TreeView_GetItem(hwndTV, &item))
|
if (!TreeView_GetItem(hwndTV, &item))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((item.state & TVIS_EXPANDEDONCE) && (item.cChildren > 0))
|
if (item.state & TVIS_EXPANDEDONCE)
|
||||||
{
|
{
|
||||||
hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
|
hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
|
||||||
SendMessageW(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
|
SendMessageW(hwndTV, TVM_SORTCHILDREN, 0, (LPARAM) hItem);
|
||||||
|
@ -645,8 +656,9 @@ BOOL TreeWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
|
||||||
|
|
||||||
UpdateAddress(pnmtv->itemNew.hItem, NULL, NULL, TRUE);
|
UpdateAddress(pnmtv->itemNew.hItem, NULL, NULL, TRUE);
|
||||||
|
|
||||||
/* Disable the Permissions menu item for 'My Computer' */
|
/* Disable the Permissions and new key menu items for 'My Computer' */
|
||||||
EnableMenuItem(hMenuFrame, ID_EDIT_PERMISSIONS, MF_BYCOMMAND | (hParentItem ? MF_ENABLED : MF_GRAYED));
|
EnableMenuItem(hMenuFrame, ID_EDIT_PERMISSIONS, MF_BYCOMMAND | (hParentItem ? MF_ENABLED : MF_GRAYED));
|
||||||
|
EnableMenuItem(hMenuFrame, ID_EDIT_NEW_KEY, MF_BYCOMMAND | (hParentItem ? MF_ENABLED : MF_GRAYED));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disable Delete/Rename menu options for 'My Computer' (first item so doesn't have any parent)
|
* Disable Delete/Rename menu options for 'My Computer' (first item so doesn't have any parent)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue