static int last_split;
HBITMAP SizingPattern = 0;
HBRUSH SizingBrush = 0;
-static TCHAR Suggestions[256];
+static WCHAR Suggestions[256];
-extern LPCTSTR get_root_key_name(HKEY hRootKey)
+extern LPCWSTR get_root_key_name(HKEY hRootKey)
{
- if (hRootKey == HKEY_CLASSES_ROOT) return _T("HKEY_CLASSES_ROOT");
- if (hRootKey == HKEY_CURRENT_USER) return _T("HKEY_CURRENT_USER");
- if (hRootKey == HKEY_LOCAL_MACHINE) return _T("HKEY_LOCAL_MACHINE");
- if (hRootKey == HKEY_USERS) return _T("HKEY_USERS");
- if (hRootKey == HKEY_CURRENT_CONFIG) return _T("HKEY_CURRENT_CONFIG");
- if (hRootKey == HKEY_DYN_DATA) return _T("HKEY_DYN_DATA");
- return _T("UKNOWN HKEY, PLEASE REPORT");
+ if (hRootKey == HKEY_CLASSES_ROOT) return L"HKEY_CLASSES_ROOT";
+ if (hRootKey == HKEY_CURRENT_USER) return L"HKEY_CURRENT_USER";
+ if (hRootKey == HKEY_LOCAL_MACHINE) return L"HKEY_LOCAL_MACHINE";
+ if (hRootKey == HKEY_USERS) return L"HKEY_USERS";
+ if (hRootKey == HKEY_CURRENT_CONFIG) return L"HKEY_CURRENT_CONFIG";
+ if (hRootKey == HKEY_DYN_DATA) return L"HKEY_DYN_DATA";
+
+ return L"UNKNOWN HKEY, PLEASE REPORT";
}
extern void ResizeWnd(int cx, int cy)
{
HTREEITEM hSelection;
HKEY hRootKey;
- LPCTSTR keyPath, s;
+ LPCWSTR keyPath, s;
WORD wID = LOWORD(wParam);
UNREFERENCED_PARAMETER(message);
case ID_EDIT_NEW_STRINGVALUE:
case ID_EDIT_NEW_BINARYVALUE:
case ID_EDIT_NEW_DWORDVALUE:
- SendMessage(hFrameWnd, WM_COMMAND, wParam, lParam);
+ SendMessageW(hFrameWnd, WM_COMMAND, wParam, lParam);
break;
case ID_SWITCH_PANELS:
g_pChildWnd->nFocusPanel = !g_pChildWnd->nFocusPanel;
while(wID > ID_TREE_SUGGESTION_MIN)
{
if (*s)
- s += _tcslen(s) + 1;
+ s += wcslen(s) + 1;
wID--;
}
SelectNode(g_pChildWnd->hTreeWnd, s);
* Key suggestion
*/
-#define MIN(a,b) ((a < b) ? (a) : (b))
+#define MIN(a,b) ((a < b) ? (a) : (b))
-static void SuggestKeys(HKEY hRootKey, LPCTSTR pszKeyPath, LPTSTR pszSuggestions,
+static void SuggestKeys(HKEY hRootKey, LPCWSTR pszKeyPath, LPWSTR pszSuggestions,
size_t iSuggestionsLength)
{
- TCHAR szBuffer[256];
- TCHAR szLastFound[256];
+ WCHAR szBuffer[256];
+ WCHAR szLastFound[256];
size_t i;
HKEY hOtherKey, hSubKey;
BOOL bFound;
iSuggestionsLength--;
/* Are we a root key in HKEY_CLASSES_ROOT? */
- if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !_tcschr(pszKeyPath, TEXT('\\')))
+ if ((hRootKey == HKEY_CLASSES_ROOT) && pszKeyPath[0] && !wcschr(pszKeyPath, L'\\'))
{
do
{
{
/* Sanity check this key; it cannot be empty, nor can it be a
* loop back */
- if ((szBuffer[0] != '\0') && _tcsicmp(szBuffer, pszKeyPath))
+ if ((szBuffer[0] != L'\0') && wcsicmp(szBuffer, pszKeyPath))
{
- if (RegOpenKey(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS)
+ if (RegOpenKeyW(hRootKey, szBuffer, &hOtherKey) == ERROR_SUCCESS)
{
- lstrcpyn(pszSuggestions, TEXT("HKCR\\"), (int) iSuggestionsLength);
- i = _tcslen(pszSuggestions);
+ wcsncpy(pszSuggestions, L"HKCR\\", (int) iSuggestionsLength);
+ i = wcslen(pszSuggestions);
pszSuggestions += i;
iSuggestionsLength -= i;
- lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength);
- i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength);
+ wcsncpy(pszSuggestions, szBuffer, (int) iSuggestionsLength);
+ i = MIN(wcslen(pszSuggestions) + 1, iSuggestionsLength);
pszSuggestions += i;
iSuggestionsLength -= i;
RegCloseKey(hOtherKey);
bFound = TRUE;
- _tcscpy(szLastFound, szBuffer);
+ wcscpy(szLastFound, szBuffer);
pszKeyPath = szLastFound;
}
}
while(bFound && (iSuggestionsLength > 0));
/* Check CLSID key */
- if (RegOpenKey(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS)
+ if (RegOpenKeyW(hRootKey, pszKeyPath, &hSubKey) == ERROR_SUCCESS)
{
- if (QueryStringValue(hSubKey, TEXT("CLSID"), NULL, szBuffer,
+ if (QueryStringValue(hSubKey, L"CLSID", NULL, szBuffer,
COUNT_OF(szBuffer)) == ERROR_SUCCESS)
{
- lstrcpyn(pszSuggestions, TEXT("HKCR\\CLSID\\"), (int) iSuggestionsLength);
- i = _tcslen(pszSuggestions);
+ wcsncpy(pszSuggestions, L"HKCR\\CLSID\\", (int)iSuggestionsLength);
+ i = wcslen(pszSuggestions);
pszSuggestions += i;
iSuggestionsLength -= i;
- lstrcpyn(pszSuggestions, szBuffer, (int) iSuggestionsLength);
- i = MIN(_tcslen(pszSuggestions) + 1, iSuggestionsLength);
+ wcsncpy(pszSuggestions, szBuffer, (int)iSuggestionsLength);
+ i = MIN(wcslen(pszSuggestions) + 1, iSuggestionsLength);
pszSuggestions += i;
iSuggestionsLength -= i;
}
LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
WNDPROC oldwndproc;
- static TCHAR s_szNode[256];
+ static WCHAR s_szNode[256];
oldwndproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(hwnd, GWL_USERDATA);
switch (uMsg)
case WM_KEYUP:
if (wParam == VK_RETURN)
{
- GetWindowText(hwnd, s_szNode, sizeof(s_szNode) / sizeof(s_szNode[0]));
+ GetWindowTextW(hwnd, s_szNode, COUNT_OF(s_szNode));
SelectNode(g_pChildWnd->hTreeWnd, s_szNode);
}
break;
return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam);
}
+static VOID
+UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath)
+{
+ LPCWSTR keyPath, rootName;
+ LPWSTR fullPath;
+
+ if (pszPath == NULL)
+ keyPath = GetItemPath(g_pChildWnd->hTreeWnd, hItem, &hRootKey);
+ else
+ keyPath = pszPath;
+
+ if (keyPath)
+ {
+ RefreshListView(g_pChildWnd->hListWnd, hRootKey, keyPath);
+ rootName = get_root_key_name(hRootKey);
+ fullPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(rootName) + 1 + wcslen(keyPath) + 1) * sizeof(WCHAR));
+ if (fullPath)
+ {
+ /* set (correct) the address bar text */
+ if (keyPath[0] != L'\0')
+ swprintf(fullPath, L"%s\\%s", rootName, keyPath);
+ else
+ fullPath = wcscpy(fullPath, rootName);
+ SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
+ SendMessageW(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
+ HeapFree(GetProcessHeap(), 0, fullPath);
+ /* disable hive manipulation items temporarily (enable only if necessary) */
+ EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED);
+ /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
+ if (!(wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") &&
+ wcsicmp(rootName, L"HKEY_USERS")))
+ {
+ /*
+ * enable the unload menu item if at the root, otherwise
+ * enable the load menu item if there is no slash in
+ * keyPath (ie. immediate child selected)
+ */
+ if(keyPath[0] == L'\0')
+ EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED);
+ else if(!wcschr(keyPath, L'\\'))
+ EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+ }
+}
+
/*******************************************************************************
*
* FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
{
WNDPROC oldproc;
HFONT hFont;
- TCHAR buffer[MAX_PATH];
- /* load "My Computer" string */
- LoadString(hInst, IDS_MY_COMPUTER, buffer, sizeof(buffer)/sizeof(TCHAR));
+ WCHAR buffer[MAX_PATH];
+
+ /* Load "My Computer" string */
+ LoadStringW(hInst, IDS_MY_COMPUTER, buffer, COUNT_OF(buffer));
g_pChildWnd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ChildWnd));
if (!g_pChildWnd) return 0;
- _tcsncpy(g_pChildWnd->szPath, buffer, MAX_PATH);
+ wcsncpy(g_pChildWnd->szPath, buffer, MAX_PATH);
g_pChildWnd->nSplitPos = 250;
g_pChildWnd->hWnd = hWnd;
- g_pChildWnd->hAddressBarWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- hWnd, (HMENU)0, hInst, 0);
- g_pChildWnd->hAddressBtnWnd = CreateWindowEx(WS_EX_CLIENTEDGE, _T("Button"), _T("»"), WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP | BS_DEFPUSHBUTTON,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- hWnd, (HMENU)0, hInst, 0);
+ g_pChildWnd->hAddressBarWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Edit", NULL, WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ hWnd, (HMENU)0, hInst, 0);
+ g_pChildWnd->hAddressBtnWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Button", L"»", WS_CHILD | WS_VISIBLE | WS_CHILDWINDOW | WS_TABSTOP | BS_DEFPUSHBUTTON,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ hWnd, (HMENU)0, hInst, 0);
g_pChildWnd->hTreeWnd = CreateTreeView(hWnd, g_pChildWnd->szPath, (HMENU) TREE_WINDOW);
g_pChildWnd->hListWnd = CreateListView(hWnd, (HMENU) LIST_WINDOW/*, g_pChildWnd->szPath*/);
SetFocus(g_pChildWnd->hTreeWnd);
if ((g_pChildWnd->hAddressBarWnd) && (g_pChildWnd->hAddressBtnWnd))
{
hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- SendMessage(g_pChildWnd->hAddressBarWnd,
- WM_SETFONT,
- (WPARAM)hFont,
- 0);
- SendMessage(g_pChildWnd->hAddressBtnWnd,
- WM_SETFONT,
- (WPARAM)hFont,
- 0);
+ SendMessageW(g_pChildWnd->hAddressBarWnd,
+ WM_SETFONT,
+ (WPARAM)hFont,
+ 0);
+ SendMessageW(g_pChildWnd->hAddressBtnWnd,
+ WM_SETFONT,
+ (WPARAM)hFont,
+ 0);
}
/* Subclass the AddressBar */
oldproc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(g_pChildWnd->hAddressBarWnd, GWL_WNDPROC);
case WM_COMMAND:
if(HIWORD(wParam) == BN_CLICKED)
{
- PostMessage(g_pChildWnd->hAddressBarWnd, WM_KEYUP, VK_RETURN, 0);
+ PostMessageW(g_pChildWnd->hAddressBarWnd, WM_KEYUP, VK_RETURN, 0);
}
if (!_CmdWndProc(hWnd, message, wParam, lParam))
ScreenToClient(hWnd, &pt);
if (pt.x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1)
{
- SetCursor(LoadCursor(0, IDC_SIZEWE));
+ SetCursor(LoadCursorW(0, IDC_SIZEWE));
return TRUE;
}
}
ResizeWnd(rt.right, rt.bottom);
last_split = -1;
ReleaseCapture();
- SetCursor(LoadCursor(0, IDC_ARROW));
+ SetCursor(LoadCursorW(0, IDC_ARROW));
}
break;
case TVN_ITEMEXPANDING:
return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
case TVN_SELCHANGED:
- {
- LPCTSTR keyPath, rootName;
- LPTSTR fullPath;
- HKEY hRootKey;
-
- keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, &hRootKey);
- if (keyPath)
- {
- RefreshListView(g_pChildWnd->hListWnd, hRootKey, keyPath);
- rootName = get_root_key_name(hRootKey);
- fullPath = HeapAlloc(GetProcessHeap(), 0, (_tcslen(rootName) + 1 + _tcslen(keyPath) + 1) * sizeof(TCHAR));
- if (fullPath)
- {
- /* set (correct) the address bar text */
- if(keyPath[0] != '\0')
- _stprintf(fullPath, _T("%s\\%s"), rootName, keyPath);
- else
- fullPath = _tcscpy(fullPath, rootName);
- SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
- SendMessage(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
- HeapFree(GetProcessHeap(), 0, fullPath);
- /* disable hive manipulation items temporarily (enable only if necessary) */
- EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED);
- /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
- if (!(_tcsicmp(rootName, TEXT("HKEY_LOCAL_MACHINE")) &&
- _tcsicmp(rootName, TEXT("HKEY_USERS"))))
- {
- // enable the unload menu item if at the root
- // otherwise enable the load menu item if there is no slash in keyPath (ie. immediate child selected)
- if(keyPath[0] == '\0')
- EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED);
- else if(!_tcschr(keyPath, _T('\\')))
- EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED);
- }
- }
- }
- }
- break;
+ UpdateAddress(((NMTREEVIEW*)lParam)->itemNew.hItem, NULL, NULL);
+ break;
case NM_SETFOCUS:
g_pChildWnd->nFocusPanel = 0;
break;
/* cancel label edit for rootkeys */
ptvdi = (LPNMTVDISPINFO) lParam;
if (!TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem) ||
- !TreeView_GetParent(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem)))
+ !TreeView_GetParent(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem)))
return TRUE;
break;
}
case TVN_ENDLABELEDIT:
{
- LPCTSTR keyPath;
+ LPCWSTR keyPath;
HKEY hRootKey;
HKEY hKey = NULL;
LPNMTVDISPINFO ptvdi;
LONG lResult = TRUE;
- TCHAR szBuffer[MAX_PATH];
+ WCHAR szBuffer[MAX_PATH];
ptvdi = (LPNMTVDISPINFO) lParam;
if (ptvdi->item.pszText)
{
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey);
- _sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("%s\\%s"), keyPath, ptvdi->item.pszText);
+ _snwprintf(szBuffer, COUNT_OF(szBuffer), L"%s\\%s", keyPath, ptvdi->item.pszText);
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey);
- if (RegOpenKeyEx(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
+ if (RegOpenKeyExW(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
lResult = FALSE;
RegCloseKey(hKey);
{
if (RenameKey(hRootKey, keyPath, ptvdi->item.pszText) != ERROR_SUCCESS)
lResult = FALSE;
+ else
+ UpdateAddress(ptvdi->item.hItem, hRootKey, szBuffer);
}
return lResult;
}
if (i != -1)
{
rc.left = LVIR_BOUNDS;
- SendMessage(g_pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc);
+ SendMessageW(g_pChildWnd->hListWnd, LVM_GETITEMRECT, i, (LPARAM) &rc);
pt.x = rc.left + 8;
pt.y = rc.top + 8;
}
HMENU hContextMenu;
TVITEM item;
MENUITEMINFO mii;
- TCHAR resource[256];
- TCHAR buffer[256];
- LPTSTR s;
- LPCTSTR keyPath;
+ WCHAR resource[256];
+ WCHAR buffer[256];
+ LPWSTR s;
+ LPCWSTR keyPath;
HKEY hRootKey;
int iLastPos;
WORD wID;
(void)TreeView_GetItem(g_pChildWnd->hTreeWnd, &item);
/* Set the Expand/Collapse menu item appropriately */
- LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, sizeof(buffer) / sizeof(buffer[0]));
+ LoadStringW(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, COUNT_OF(buffer));
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID;
mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED;
mii.wID = (item.state & TVIS_EXPANDED) ? ID_TREE_COLLAPSEBRANCH : ID_TREE_EXPANDBRANCH;
- mii.dwTypeData = (LPTSTR) buffer;
+ mii.dwTypeData = (LPWSTR) buffer;
SetMenuItemInfo(hContextMenu, 0, TRUE, &mii);
/* Remove any existing suggestions */
/* Come up with suggestions */
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, NULL, &hRootKey);
- SuggestKeys(hRootKey, keyPath, Suggestions, sizeof(Suggestions) / sizeof(Suggestions[0]));
+ SuggestKeys(hRootKey, keyPath, Suggestions, COUNT_OF(Suggestions));
if (Suggestions[0])
{
AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL);
- LoadString(hInst, IDS_GOTO_SUGGESTED_KEY, resource, sizeof(resource) / sizeof(resource[0]));
+ LoadStringW(hInst, IDS_GOTO_SUGGESTED_KEY, resource, COUNT_OF(resource));
s = Suggestions;
wID = ID_TREE_SUGGESTION_MIN;
while(*s && (wID <= ID_TREE_SUGGESTION_MAX))
{
- _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), resource, s);
+ _snwprintf(buffer, COUNT_OF(buffer), resource, s);
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.dwTypeData = buffer;
InsertMenuItem(hContextMenu, GetMenuItemCount(hContextMenu), TRUE, &mii);
- s += _tcslen(s) + 1;
+ s += wcslen(s) + 1;
}
}
TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, g_pChildWnd->hWnd, NULL);
/* fall through */
default:
def:
- return DefWindowProc(hWnd, message, wParam, lParam);
+ return DefWindowProcW(hWnd, message, wParam, lParam);
}
return 0;
}