Skip to content

Commit

Permalink
Non working close button in the modify dialog. Fixes #99.
Browse files Browse the repository at this point in the history
  • Loading branch information
jovibor committed Jan 8, 2025
1 parent f307500 commit da3faf6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 37 deletions.
64 changes: 32 additions & 32 deletions HexCtrl/src/Dialogs/CHexDlgBkmMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ auto CHexDlgBkmMgr::AddBkm(const HEXBKM& hbs, bool fRedraw)->ULONGLONG
else {
ullID = 1; //Bookmarks' ID starts from 1.
if (const auto iter = std::max_element(m_vecBookmarks.begin(), m_vecBookmarks.end(),
[](const HEXBKM& ref1, const HEXBKM& ref2) {
return ref1.ullID < ref2.ullID; }); iter != m_vecBookmarks.end()) {
[](const HEXBKM& lhs, const HEXBKM& rhs) {
return lhs.ullID < rhs.ullID; }); iter != m_vecBookmarks.end()) {
ullID = iter->ullID + 1; //Increasing next bookmark's ID by 1.
}
m_vecBookmarks.emplace_back(hbs.vecSpan, hbs.wstrDesc, ullID, hbs.ullData, hbs.stClr);
Expand Down Expand Up @@ -183,8 +183,8 @@ auto CHexDlgBkmMgr::HitTest(ULONGLONG ullOffset)->PHEXBKM
if (const auto rIter = std::find_if(m_vecBookmarks.rbegin(), m_vecBookmarks.rend(),
[ullOffset](const HEXBKM& ref) { return std::any_of(ref.vecSpan.begin(), ref.vecSpan.end(),
[ullOffset](const HEXSPAN& refV) {
return ullOffset >= refV.ullOffset && ullOffset < (refV.ullOffset + refV.ullSize); }); });
rIter != m_vecBookmarks.rend()) {
return ullOffset >= refV.ullOffset && ullOffset < (refV.ullOffset + refV.ullSize); }); });
rIter != m_vecBookmarks.rend()) {
pBkm = &*rIter;
}
}
Expand Down Expand Up @@ -260,7 +260,7 @@ void CHexDlgBkmMgr::RemoveByOffset(ULONGLONG ullOffset)
if (const auto iter = std::find_if(m_vecBookmarks.rbegin(), m_vecBookmarks.rend(),
[ullOffset](const HEXBKM& ref) { return std::any_of(ref.vecSpan.begin(), ref.vecSpan.end(),
[ullOffset](const HEXSPAN& refV) {
return ullOffset >= refV.ullOffset && ullOffset < (refV.ullOffset + refV.ullSize); }); });
return ullOffset >= refV.ullOffset && ullOffset < (refV.ullOffset + refV.ullSize); }); });
iter != m_vecBookmarks.rend()) {
RemoveBookmark(iter->ullID);
}
Expand Down Expand Up @@ -319,34 +319,34 @@ void CHexDlgBkmMgr::SortData(int iColumn, bool fAscending)
//iColumn is column number in CHexDlgBkmMgr::m_ListEx.
std::sort(m_vecBookmarks.begin(), m_vecBookmarks.end(),
[iColumn, fAscending](const HEXBKM& st1, const HEXBKM& st2) {
int iCompare { };
switch (iColumn) {
case 0:
break;
case 1: //Offset.
if (!st1.vecSpan.empty() && !st2.vecSpan.empty()) {
const auto ullOffset1 = st1.vecSpan.front().ullOffset;
const auto ullOffset2 = st2.vecSpan.front().ullOffset;
iCompare = ullOffset1 != ullOffset2 ? (ullOffset1 < ullOffset2 ? -1 : 1) : 0;
}
break;
case 2: //Size.
if (!st1.vecSpan.empty() && !st2.vecSpan.empty()) {
auto ullSize1 = std::reduce(st1.vecSpan.begin(), st1.vecSpan.end(), 0ULL,
[](auto ullTotal, const HEXSPAN& ref) { return ullTotal + ref.ullSize; });
auto ullSize2 = std::reduce(st2.vecSpan.begin(), st2.vecSpan.end(), 0ULL,
[](auto ullTotal, const HEXSPAN& ref) { return ullTotal + ref.ullSize; });
iCompare = ullSize1 != ullSize2 ? (ullSize1 < ullSize2 ? -1 : 1) : 0;
int iCompare { };
switch (iColumn) {
case 0:
break;
case 1: //Offset.
if (!st1.vecSpan.empty() && !st2.vecSpan.empty()) {
const auto ullOffset1 = st1.vecSpan.front().ullOffset;
const auto ullOffset2 = st2.vecSpan.front().ullOffset;
iCompare = ullOffset1 != ullOffset2 ? (ullOffset1 < ullOffset2 ? -1 : 1) : 0;
}
break;
case 2: //Size.
if (!st1.vecSpan.empty() && !st2.vecSpan.empty()) {
auto ullSize1 = std::reduce(st1.vecSpan.begin(), st1.vecSpan.end(), 0ULL,
[](auto ullTotal, const HEXSPAN& ref) { return ullTotal + ref.ullSize; });
auto ullSize2 = std::reduce(st2.vecSpan.begin(), st2.vecSpan.end(), 0ULL,
[](auto ullTotal, const HEXSPAN& ref) { return ullTotal + ref.ullSize; });
iCompare = ullSize1 != ullSize2 ? (ullSize1 < ullSize2 ? -1 : 1) : 0;
}
break;
case 3: //Description.
iCompare = st1.wstrDesc.compare(st2.wstrDesc);
break;
default:
break;
}
break;
case 3: //Description.
iCompare = st1.wstrDesc.compare(st2.wstrDesc);
break;
default:
break;
}

return fAscending ? iCompare < 0 : iCompare > 0;
return fAscending ? iCompare < 0 : iCompare > 0;
});
}

Expand Down Expand Up @@ -392,7 +392,7 @@ void CHexDlgBkmMgr::OnCancel()
if (IsNoEsc()) //Not closing Dialog on Escape key.
return;

ShowWindow(SW_HIDE);
OnClose();
}

auto CHexDlgBkmMgr::OnClose()->INT_PTR
Expand Down
2 changes: 1 addition & 1 deletion HexCtrl/src/Dialogs/CHexDlgCodepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void CHexDlgCodepage::OnCancel()
if (IsNoEsc()) //Not closing Dialog on Escape key.
return;

ShowWindow(SW_HIDE);
OnClose();
}

auto CHexDlgCodepage::OnClose()->INT_PTR
Expand Down
2 changes: 1 addition & 1 deletion HexCtrl/src/Dialogs/CHexDlgDataInterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void CHexDlgDataInterp::OnCancel()
if (IsNoEsc()) //Not closing Dialog on Escape key.
return;

ShowWindow(SW_HIDE);
OnClose();
}

void CHexDlgDataInterp::OnCheckHex()
Expand Down
2 changes: 1 addition & 1 deletion HexCtrl/src/Dialogs/CHexDlgGoTo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void CHexDlgGoTo::OnCancel()
if (IsNoEsc()) //Not closing Dialog on Escape key.
return;

ShowWindow(SW_HIDE);
OnClose();
}

auto CHexDlgGoTo::OnClose()->INT_PTR
Expand Down
1 change: 1 addition & 0 deletions HexCtrl/src/Dialogs/CHexDlgModify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ auto CHexDlgModify::ProcessMsg(const MSG& msg)->INT_PTR
{
switch (msg.message) {
case WM_ACTIVATE: return OnActivate(msg);
case WM_CLOSE: return OnClose();
case WM_DESTROY: return OnDestroy();
case WM_INITDIALOG: return OnInitDialog(msg);
case WM_NOTIFY: return OnNotify(msg);
Expand Down
2 changes: 1 addition & 1 deletion HexCtrl/src/Dialogs/CHexDlgSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ void CHexDlgSearch::OnCancel()
if (IsNoEsc()) //Not closing Dialog on Escape key.
return;

ShowWindow(SW_HIDE);
OnClose();
}

void CHexDlgSearch::OnCheckSel()
Expand Down
2 changes: 1 addition & 1 deletion HexCtrl/src/Dialogs/CHexDlgTemplMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ void CHexDlgTemplMgr::OnCancel()
if (IsNoEsc()) //Not closing Dialog on Escape key.
return;

ShowWindow(SW_HIDE);
OnClose();
}

void CHexDlgTemplMgr::OnCheckHex()
Expand Down

0 comments on commit da3faf6

Please sign in to comment.