简体   繁体   English

Clistctrl选择检测

[英]Clistctrl selection detect

I've been playing with the list view and came across this post: How to detect a CListCtrl selection change? 我一直在使用列表视图,并且遇到了这篇文章: 如何检测CListCtrl选择更改?

However the code used there has a major flow, it doesn't work with multiple selection (as pointed out in that thread). 但是,那里使用的代码流程繁重,无法与多重选择一起使用(如该线程中所指出的)。 So my question is how can I make the code work with multiselection (eg. selection with shift or ctrl)? 所以我的问题是如何使代码与多重选择一起工作(例如,使用shift或ctrl进行选择)?

I've written a handy function to see if your OnItemChanged notification was due to a selection change: 我编写了一个方便的函数来查看您的OnItemChanged通知是否是由于选择更改引起的:

BOOL IsItemSelChanged(NMLISTVIEW* pNMListView)
{
    // call this from your OnItemchangedMyListCtrl function in your dialog class

    if(!(pNMListView->uChanged & LVIF_STATE))
    {
        return(FALSE);
    }

    if((pNMListView->uOldState & LVIS_SELECTED) == (pNMListView->uNewState & LVIS_SELECTED))
    {
        return(FALSE);
    }

    return(TRUE);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM