MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / OnEditDelete

Method OnEditDelete

WinArk/View.cpp:1264–1317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1262}
1263
1264LRESULT CRegistryManagerView::OnEditDelete(WORD, WORD, HWND, BOOL&){
1265 if (::GetFocus() == m_Tree) {
1266 auto hItem = m_Tree.GetSelectedItem();
1267 auto path = GetFullParentNodePath(hItem);
1268 CString name;
1269 m_Tree.GetItemText(hItem, name);
1270 auto cmd = std::make_shared<DeleteKeyCommand>(path, name, GetDeleteKeyCommandCallback());
1271 if (!m_CmdMgr.AddCommand(cmd))
1272 DisplayError(L"Failed to delete key");
1273 }
1274 else if (::GetFocus() == m_List) {
1275 auto count = m_List.GetSelectedCount();
1276 ATLASSERT(count >= 1);
1277 int index = -1;
1278 auto cb = [this](auto& cmd, auto) {
1279 auto cmd0 = std::static_pointer_cast<DeleteValueCommand>(cmd.GetCommand(0));
1280 if (GetFullNodePath(m_Tree.GetSelectedItem()) == cmd0->GetPath()) {
1281 RefreshItem(m_Tree.GetSelectedItem());
1282 UpdateList();
1283 }
1284 return true;
1285 };
1286
1287 auto list = std::make_shared<AppCommandList>(L"", cb);
1288 auto path = GetFullNodePath(m_Tree.GetSelectedItem());
1289 for (UINT i = 0; i < count; i++) {
1290 index = m_List.GetNextItem(index, LVIS_SELECTED);
1291 ATLASSERT(index >= 0);
1292 auto& item = m_Items[index];
1293 if (item.Type == REG_KEY_UP) {
1294 count--;
1295 continue;
1296 }
1297 std::shared_ptr<AppCommand> cmd;
1298 if (item.Key) {
1299 cmd = std::make_shared<DeleteKeyCommand>(path, item.Name);
1300 }
1301 else {
1302 cmd = std::make_shared<DeleteValueCommand>(path, item.Name);
1303 }
1304 list->AddCommand(cmd);
1305 }
1306 if (count == 1) // only up key selected
1307 return 0;
1308
1309 if (count == 1)
1310 list->SetCommandName(list->GetCommand(0)->GetCommandName());
1311 else
1312 list->SetCommandName(L"Delete");
1313 if (!m_CmdMgr.AddCommand(list))
1314 DisplayError(L"Delete failed.");
1315 }
1316 return 0;
1317}
1318
1319LRESULT CRegistryManagerView::OnCopyFullKeyName(WORD, WORD, HWND, BOOL&){
1320 ClipboardHelper::CopyText(m_hWnd, GetFullNodePath(m_Tree.GetSelectedItem()));

Callers

nothing calls this directly

Calls 4

GetCommandMethod · 0.80
GetPathMethod · 0.80
AddCommandMethod · 0.45
GetCommandNameMethod · 0.45

Tested by

no test coverage detected