!难-ListView多选的控制 让ListView只能选一行或一块,不能选分离的行。也就是禁止掉Ctrl+选择方式。怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在属性里的Styles栏里,把single selection标上 喔,看错题了.在PreTranslateMessage里处理WM_KEYDOWN消息,判断Ctrl按下时,直接返回. 派生一个ListView,在PreTranslateMessage中屏蔽掉Ctrl键的消息 code project里有很多这方面的源码阿,建议lz去研究研究 派生一个ListView,在PreTranslateMessage中屏蔽掉Ctrl键的消息===========================================================对于按住Ctrl+MouseLeft是无效的 你试试看void CYourList::OnLButtonDown(UINT nFlags, CPoint point) {// TODO: Add your message handler code here and/or call defaultif (GetKeyState(VK_CONTROL)&0x80) return ;// .....CListCtrl::OnLButtonDown(nFlags, point);} 对于按住Ctrl+MouseLeft是无效的===========================================================Who says?BOOL CYourList::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class BOOL b = GetAsyncKeyState(VK_CONTROL) >> ((sizeof(short) * 8)-1); if(b) { b = GetAsyncKeyState(MK_LBUTTON) >> ((sizeof(short) * 8)-1); if(b) return TRUE; } return CListCtrl::PreTranslateMessage(pMsg);} 处理LVN_ITEMCHANGING,1、若(uNewState&LVIS_SELECTED)==0 return 0;2、ListView_GetNextItem找有无选中的item,若无,return 0L;3、判断该iItem-1/iItem+1的选中状态,若均未选中,则return TRUE; //阻止该item被选择。4、return 0L; //允许选中 LS这样也不行。如选择了1,2,3,4用Ctrl+MouseLeft反选3.那问题就更大。 BOOL CYourList::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class BOOL b = GetAsyncKeyState(VK_CONTROL) >> ((sizeof(short) * 8)-1); if(b) { b = GetAsyncKeyState(MK_LBUTTON) >> ((sizeof(short) * 8)-1); if(b) return TRUE; } return CListCtrl::PreTranslateMessage(pMsg);}=============================================好象可以,这是屏蔽了Ctrl消息或屏蔽了MouseLeft消息? 麻烦大家看一下,这个opengl的程序,为啥点击右键后图像没有刷新? 期待vs2010不是一个传说 VC 串口通讯 移植 急啊!!!!! 表的问题!!!!!!!!!!!!!!!!!! 命令行程序很在DOS下运行吗?怎样才能用VC编DOS程序? 讨论:并发控制 vc6附带的InstallShield中LauchApp是不能用的吗?帮助中说unavailable,请大家指教,谢谢! 请问客户端在connect之前如何判断服务端端口正常启动? 请教:非模态对话框的问题 急!!!! 谁说过TRUE == 1的? 每个类中的 m_hWnd 和 this 有什么区别? vfw 中设置帧率问题!!
在PreTranslateMessage里处理WM_KEYDOWN消息,判断Ctrl按下时,直接返回.
===========================================================
对于按住Ctrl+MouseLeft是无效的
{
// TODO: Add your message handler code here and/or call defaultif (GetKeyState(VK_CONTROL)&0x80)
return ;// .....CListCtrl::OnLButtonDown(nFlags, point);
}
===========================================================
Who says?BOOL CYourList::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
BOOL b = GetAsyncKeyState(VK_CONTROL) >> ((sizeof(short) * 8)-1);
if(b)
{
b = GetAsyncKeyState(MK_LBUTTON) >> ((sizeof(short) * 8)-1);
if(b)
return TRUE;
}
return CListCtrl::PreTranslateMessage(pMsg);
}
1、若(uNewState&LVIS_SELECTED)==0 return 0;
2、ListView_GetNextItem找有无选中的item,若无,return 0L;
3、判断该iItem-1/iItem+1的选中状态,若均未选中,则return TRUE; //阻止该item被选择。
4、return 0L; //允许选中
如选择了1,2,3,4
用Ctrl+MouseLeft反选3.那问题就更大。
{
// TODO: Add your specialized code here and/or call the base class
BOOL b = GetAsyncKeyState(VK_CONTROL) >> ((sizeof(short) * 8)-1);
if(b)
{
b = GetAsyncKeyState(MK_LBUTTON) >> ((sizeof(short) * 8)-1);
if(b)
return TRUE;
}
return CListCtrl::PreTranslateMessage(pMsg);
}
=============================================
好象可以,这是屏蔽了Ctrl消息或屏蔽了MouseLeft消息?