regedit: Convert the listview code to Unicode.

This commit is contained in:
Andrew Nguyen 2011-04-16 03:07:27 -05:00 committed by Alexandre Julliard
parent 172ce3eed8
commit 87bd8ef6e1
1 changed files with 26 additions and 19 deletions

View File

@ -85,7 +85,7 @@ LPCWSTR GetValueName(HWND hwndLV)
HeapFree(GetProcessHeap(), 0, g_valueName); HeapFree(GetProcessHeap(), 0, g_valueName);
g_valueName = NULL; g_valueName = NULL;
item = ListView_GetNextItem(hwndLV, -1, LVNI_FOCUSED); item = SendMessageW(hwndLV, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_FOCUSED, 0));
if (item == -1) return NULL; if (item == -1) return NULL;
g_valueName = GetItemText(hwndLV, item); g_valueName = GetItemText(hwndLV, item);
@ -133,7 +133,7 @@ static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType,
} }
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE; item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
item.iItem = ListView_GetItemCount(hwndLV);/*idx; */ item.iItem = SendMessageW(hwndLV, LVM_GETITEMCOUNT, 0, 0);
item.iSubItem = 0; item.iSubItem = 0;
item.state = 0; item.state = 0;
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED; item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
@ -348,12 +348,12 @@ HWND StartValueRename(HWND hwndLV)
{ {
int item; int item;
item = ListView_GetNextItem(hwndLV, -1, LVNI_FOCUSED | LVNI_SELECTED); item = SendMessageW(hwndLV, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
if (item < 1) { /* cannot rename default key */ if (item < 1) { /* cannot rename default key */
MessageBeep(MB_ICONHAND); MessageBeep(MB_ICONHAND);
return 0; return 0;
} }
return ListView_EditLabel(hwndLV, item); return (HWND)SendMessageW(hwndLV, LVM_EDITLABELW, item, 0);
} }
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@ -372,7 +372,7 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
switch (message) { switch (message) {
case WM_COMMAND: case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam)) { if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); return CallWindowProcW(g_orgListWndProc, hWnd, message, wParam, lParam);
} }
break; break;
case WM_NOTIFY_REFLECT: case WM_NOTIFY_REFLECT:
@ -409,7 +409,7 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
return 0; return 0;
} }
case NM_RETURN: { case NM_RETURN: {
int cnt = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED | LVNI_SELECTED); int cnt = SendMessageW(hWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
if (cnt != -1) if (cnt != -1)
SendMessageW(hFrameWnd, WM_COMMAND, ID_EDIT_MODIFY, 0); SendMessageW(hFrameWnd, WM_COMMAND, ID_EDIT_MODIFY, 0);
} }
@ -435,10 +435,17 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
#endif #endif
info.pt.x = nmitem->ptAction.x; info.pt.x = nmitem->ptAction.x;
info.pt.y = nmitem->ptAction.y; info.pt.y = nmitem->ptAction.y;
if (ListView_HitTest(hWnd, &info) != -1) { if (SendMessageW(hWnd, LVM_HITTEST, 0, (LPARAM)&info) != -1) {
ListView_SetItemState(hWnd, -1, 0, LVIS_FOCUSED|LVIS_SELECTED); LVITEMW item;
ListView_SetItemState(hWnd, info.iItem, LVIS_FOCUSED|LVIS_SELECTED,
LVIS_FOCUSED|LVIS_SELECTED); item.state = 0;
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
SendMessageW(hWnd, LVM_SETITEMSTATE, (UINT)-1, (LPARAM)&item);
item.state = LVIS_FOCUSED | LVIS_SELECTED;
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
SendMessageW(hWnd, LVM_SETITEMSTATE, info.iItem, (LPARAM)&item);
SendMessageW(hFrameWnd, WM_COMMAND, ID_EDIT_MODIFY, 0); SendMessageW(hFrameWnd, WM_COMMAND, ID_EDIT_MODIFY, 0);
} }
} }
@ -449,14 +456,14 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
} }
break; break;
case WM_CONTEXTMENU: { case WM_CONTEXTMENU: {
int cnt = ListView_GetNextItem(hWnd, -1, LVNI_SELECTED); int cnt = SendMessageW(hWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_SELECTED, 0));
TrackPopupMenu(GetSubMenu(hPopupMenus, cnt == -1 ? PM_NEW : PM_MODIFYVALUE), TrackPopupMenu(GetSubMenu(hPopupMenus, cnt == -1 ? PM_NEW : PM_MODIFYVALUE),
TPM_RIGHTBUTTON, (short)LOWORD(lParam), (short)HIWORD(lParam), TPM_RIGHTBUTTON, (short)LOWORD(lParam), (short)HIWORD(lParam),
0, hFrameWnd, NULL); 0, hFrameWnd, NULL);
break; break;
} }
default: default:
return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); return CallWindowProcW(g_orgListWndProc, hWnd, message, wParam, lParam);
} }
return 0; return 0;
} }
@ -512,11 +519,11 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
errCode = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ, &hKey); errCode = RegOpenKeyExW(hKeyRoot, keyPath, 0, KEY_READ, &hKey);
if (errCode != ERROR_SUCCESS) goto done; if (errCode != ERROR_SUCCESS) goto done;
count = ListView_GetItemCount(hwndLV); count = SendMessageW(hwndLV, LVM_GETITEMCOUNT, 0, 0);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
item.mask = LVIF_PARAM; item.mask = LVIF_PARAM;
item.iItem = i; item.iItem = i;
SendMessageW( hwndLV, LVM_GETITEM, 0, (LPARAM)&item ); SendMessageW( hwndLV, LVM_GETITEMW, 0, (LPARAM)&item );
HeapFree(GetProcessHeap(), 0, ((LINE_INFO*)item.lParam)->name); HeapFree(GetProcessHeap(), 0, ((LINE_INFO*)item.lParam)->name);
HeapFree(GetProcessHeap(), 0, (void*)item.lParam); HeapFree(GetProcessHeap(), 0, (void*)item.lParam);
} }