Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the "Line Filters" dialog. #2047

Merged
merged 1 commit into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion Src/LineFiltersDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ BEGIN_MESSAGE_MAP(LineFiltersDlg, CTrPropertyPage)
ON_NOTIFY(LVN_ITEMACTIVATE, IDC_LFILTER_LIST, OnLvnItemActivateLfilterList)
ON_NOTIFY(LVN_KEYDOWN, IDC_LFILTER_LIST, OnLvnKeyDownLfilterList)
ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LFILTER_LIST, OnEndLabelEditLfilterList)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LFILTER_LIST, OnLvnItemChangedLfilterList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

Expand All @@ -70,7 +71,8 @@ BOOL LineFiltersDlg::OnInitDialog()
CTrPropertyPage::OnInitDialog();

InitList();

SetButtonState();

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Expand Down Expand Up @@ -236,3 +238,32 @@ void LineFiltersDlg::OnEndLabelEditLfilterList(NMHDR *pNMHDR, LRESULT *pResult)
{
*pResult = 1;
}

/**
* @brief Called when item state is changed.
*
* Disable "Edit" and "Remove" buttons when no item is selected.
* @param [in] pNMHDR Listview item data.
* @param [out] pResult Result of the action is returned in here.
*/
void LineFiltersDlg::OnLvnItemChangedLfilterList(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
if ((pNMLV->uOldState & LVIS_SELECTED) != (pNMLV->uNewState & LVIS_SELECTED))
{
SetButtonState();
}
*pResult = 0;
}

/**
* @brief Disable "Edit" and "Remove" buttons when no item is selected.
*/
void LineFiltersDlg::SetButtonState()
{
int sel = -1;
sel = m_filtersList.GetNextItem(sel, LVNI_SELECTED);
bool bIsSelected = (sel != -1);
EnableDlgItem(IDC_LFILTER_EDITBTN, bIsSelected);
EnableDlgItem(IDC_LFILTER_REMOVEBTN, bIsSelected);
}
3 changes: 3 additions & 0 deletions Src/LineFiltersDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class LineFiltersDlg : public CTrPropertyPage
afx_msg void OnLvnItemActivateLfilterList(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLvnKeyDownLfilterList(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnEndLabelEditLfilterList(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLvnItemChangedLfilterList(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

Expand All @@ -63,4 +64,6 @@ class LineFiltersDlg : public CTrPropertyPage
CListCtrl m_filtersList; /**< List control having filter strings */

LineFiltersList * m_pList; /**< Helper list for getting/setting filters. */

void SetButtonState();
};