如题,请问如何删除listbox选中的多行记录,同时如何设置ctrl+A键来全选记录?
解决方案 »
- 程序SetTimer(1,100,NULL)后,退出程序时要不要KillTimer(1)?
- 求助界面美化
- 使用MSXML2::IXMLHTTPRequestPtr 对象问题?
- vc6.0编译出错
- 求助
- 如何在主程序等线程执行完后再接着执行后边的程序
- 如何将浮点型数据转化为字符型呀?
- 把某个类的.cpp文件和.h文件移了一个文件夹后,在“建立类向导 。。。”里找不到这个类了,但不知如何才能使这个类出现
- 这种错误的原因是头文件吗?
- 诸位,我的VC又出鬼了(调试器)!!!
- 求一个接口简单的AES算法库,支持x86 & x64
- 出现了应用程序错误:"Ox5f42d92d"指令引用的"Ox33462864"内存。该内存不能为"read".这是什么原因造成的?
int GetSelItems( int nMaxItems, LPINT rgIndex ) const;Return ValueThe actual number of items placed in the buffer. If the list box is a single-selection list box, the return value is LB_ERR.CListBox::SelItemRange
int SelItemRange( BOOL bSelect, int nFirstItem, int nLastItem );
int nCount = m_list.GetSelectedCount();
int* buf = new int[nCount];
memset(buf, -1, sizeof(int)*nCount); int nIndex = 0;
POSITION pos = m_list.GetFirstSelectedItemPosition();
while(pos)
{
int nTmp = m_list.GetNextSelectedItem(pos);
buf[nIndex++] = nTmp;
} for(int i=nIndex-1; i>=0; i--)
{
m_list.DeleteItem(buf[i]);
} delete[] buf;
// 删除所选的项
int nCount = m_listBox.GetSelCount();
int* buffer = new int[nCount];
memset(buffer, -1, sizeof(int)*nCount); m_listBox.GetSelItems(nCount, buffer); for(int i=nCount-1; i>=0; i--)
{
m_listBox.DeleteString(buffer[i]);
}
delete[] buffer;// Ctrl+A选择所有的Item,也可以注册系统Hotkey
BOOL CXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_KEYDOWN == pMsg->message && _T('A') == pMsg->wParam)
{
if(HIBYTE(GetKeyState(VK_CONTROL)))
{
m_listBox.SelItemRange(TRUE, 0, m_listBox.GetCount());
}
}
return CDialog::PreTranslateMessage(pMsg);
}