Skip to content

Commit

Permalink
possible fix for stuck refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
zodiacon committed Nov 2, 2023
1 parent 7eeb8e5 commit b989e47
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions RegExp/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,15 @@ LRESULT CMainFrame::OnListItemChanged(int, LPNMHDR, BOOL&) {
}

LRESULT CMainFrame::OnViewRefresh(WORD, WORD, HWND, BOOL&) {
m_Tree.SetRedraw(FALSE);
RefreshFull(m_hStdReg);
RefreshFull(m_hRealReg);
m_Tree.SetRedraw(TRUE);
UpdateList();
auto hCurrent = m_Tree.GetSelectedItem();
TreeHelper th(m_Tree);
th.DoForEachItem(m_hStdReg, 0, [this](auto hItem, auto state) {
RefreshItem(hItem);
});
th.DoForEachItem(m_hRealReg, 0, [this](auto hItem, auto state) {
RefreshItem(hItem);
});
m_Tree.EnsureVisible(hCurrent);
return 0;
}

Expand Down Expand Up @@ -1978,7 +1982,7 @@ void CMainFrame::RefreshFull(HTREEITEM hItem) {
}
else {
// really expanded
RefreshFull(hItem);
//RefreshFull(hItem);
auto key = Registry::OpenKey(GetFullNodePath(hItem), KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS);
if (key) {
auto keys = th.GetChildItems(hItem);
Expand Down Expand Up @@ -2148,15 +2152,18 @@ CString CMainFrame::GetValueDetails(const RegistryItem& item) const {
}

bool CMainFrame::RefreshItem(HTREEITEM hItem) {
auto expanded = m_Tree.GetItemState(hItem, TVIS_EXPANDED);
m_Tree.LockWindowUpdate();
auto expanded = m_Tree.GetItemState(hItem, TVIS_EXPANDED | TVIS_EXPANDEDONCE);
if (expanded == 0)
return false;

m_Tree.SetRedraw(FALSE);
m_Tree.Expand(hItem, TVE_COLLAPSE | TVE_COLLAPSERESET);
TreeHelper th(m_Tree);
th.DeleteChildren(hItem);
m_Tree.InsertItem(L"\\\\", hItem, TVI_LAST);
if (expanded)
if (expanded & TVIS_EXPANDED)
m_Tree.Expand(hItem, TVE_EXPAND);
m_Tree.LockWindowUpdate(FALSE);
m_Tree.SetRedraw();
UpdateList();
return true;
}
Expand Down
Binary file modified RegExp/RegExp.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion RegExp/TreeHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void TreeHelper::DoForEachItem(HTREEITEM hRoot, DWORD mask, std::function<void(H
ATLTRACE(L"DoForEachExpanded hItem: 0x%p (%s)\n", hItem, text);
#endif
auto state = _tv.GetItemState(hItem, mask);
if (state) {
if (mask == 0 || state) {
action(hItem, state);
DoForEachItem(hItem, mask, action);
}
Expand Down

0 comments on commit b989e47

Please sign in to comment.