| 1366 | } |
| 1367 | |
| 1368 | INT_PTR CRegistryManagerView::ShowValueProperties(RegistryItem& item, int index) { |
| 1369 | auto cb = [this](auto& cmd, bool) { |
| 1370 | if (GetFullNodePath(m_Tree.GetSelectedItem()) == cmd.GetPath()) { |
| 1371 | int index = m_List.FindItem(cmd.GetName(), false); |
| 1372 | ATLASSERT(index >= 0); |
| 1373 | if (index >= 0) { |
| 1374 | m_Items[index].Value.Empty(); |
| 1375 | m_Items[index].Size -= 1; |
| 1376 | m_List.RedrawItems(index, index); |
| 1377 | m_List.SetItemState(index, LVIS_SELECTED, LVIS_SELECTED); |
| 1378 | } |
| 1379 | } |
| 1380 | return true; |
| 1381 | }; |
| 1382 | bool success = false; |
| 1383 | bool result = false; |
| 1384 | switch (item.Type) |
| 1385 | { |
| 1386 | case REG_LINK: |
| 1387 | AtlMessageBox(m_hWnd, L"No special properties available for a symbolic link", IDS_TITLE, MB_ICONINFORMATION); |
| 1388 | return 0; |
| 1389 | |
| 1390 | case REG_SZ: |
| 1391 | case REG_EXPAND_SZ: |
| 1392 | { |
| 1393 | CStringValueDlg dlg(m_CurrentKey, item.Name, m_ReadOnly); |
| 1394 | result = dlg.DoModal() == IDOK && dlg.IsModified(); |
| 1395 | if (result) { |
| 1396 | auto hItem = m_Tree.GetSelectedItem(); |
| 1397 | DWORD type = dlg.GetType(); |
| 1398 | CString value = dlg.GetValue(); |
| 1399 | LONG size = (1 + value.GetLength()) * sizeof(WCHAR); |
| 1400 | auto cmd = std::make_shared<ChangeValueCommand>(GetFullNodePath(hItem), |
| 1401 | item.Name, type, (PVOID)(PCWSTR)value,size); |
| 1402 | success = m_CmdMgr.AddCommand(cmd); |
| 1403 | if (success) { |
| 1404 | cmd->SetCallback(cb); |
| 1405 | item.Value.Empty(); |
| 1406 | item.Size -= 1; |
| 1407 | m_List.RedrawItems(index, index); |
| 1408 | } |
| 1409 | } |
| 1410 | break; |
| 1411 | } |
| 1412 | |
| 1413 | case REG_MULTI_SZ: |
| 1414 | { |
| 1415 | CMultiStringValueDlg dlg(m_CurrentKey, item.Name, m_ReadOnly); |
| 1416 | result = dlg.DoModal() == IDOK && dlg.IsModified(); |
| 1417 | if (result) { |
| 1418 | auto hItem = m_Tree.GetSelectedItem(); |
| 1419 | auto value = dlg.GetValue(); |
| 1420 | // �����Ŀ���ַ������е���һ�ַ���ֱ��������һ��������Ŀ���ַ����Ӽ����ַ�Ϊֹ |
| 1421 | value.TrimRight(L"\r\n"); |
| 1422 | value.Replace(L"\r\n", L"\n"); |
| 1423 | auto len = value.GetLength(); |
| 1424 | for (int i = 0; i < len; i++) { |
| 1425 | if (value[i] == L'\n') |
nothing calls this directly
no test coverage detected