这个好解决,在以上人员答案进行综合!响应你CListbox 控件所在的form PreTranslateMessage 取控件handle 然后switch ID case listbox1-ID: case listbox2-ID: case listbox3--ID: - - { -- -- -- }
提示一点,自己在思考看,这样水平提高会很快:)
void CNeedForCheckingDlg::OnButton6() // Delete FIles { // TODO: Add your control notification handler code here int sel_count = flb->GetSelCount();// flb是CListBox类 int count[100]; flb->GetSelItems( sel_count, count ); for( int i = 0; i < sel_count; i++ ) { flb->DeleteString( count[i] - i ); } }
截获WM_KEYDOW
当wparam为VK_DELETE及当前的焦点在CListBox上时
do itps:CListBox::GetCurSel//single selected
CListBox::DeleteString
//多行,aryListBoxSel的值就是索引号
int nCount = pmyListBox->GetSelCount();
CArray<int,int> aryListBoxSel;aryListBoxSel.SetSize(nCount);
pmyListBox->GetSelItems(nCount, aryListBoxSel.GetData());
安全一点的是::GetFocus() ==GetDlgItem(IDC_LISTBOX1)->GetSafeWnd()
有更好的吗?
PreTranslateMessage
取控件handle
然后switch ID
case listbox1-ID:
case listbox2-ID:
case listbox3--ID:
-
-
{
--
--
--
}
提示一点,自己在思考看,这样水平提高会很快:)
{
// TODO: Add your control notification handler code here
int sel_count = flb->GetSelCount();// flb是CListBox类
int count[100];
flb->GetSelItems( sel_count, count );
for( int i = 0; i < sel_count; i++ ) {
flb->DeleteString( count[i] - i );
}
}