CListCtrl中的曲目选择(或悬停) [英] track select (or hover) in CListCtrl

查看:438
本文介绍了CListCtrl中的曲目选择(或悬停)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑我的原始问题(如下所示)有问题.我发现我要增强的系统已经跟踪了光标的移动,并且我很确定这不会使我陷入困境.该代码相当庞大(超过800万行代码),而且并不总是立即就可以证明您可能正在尝试做的事情已经在其他地方完成了.无论如何,我相信我需要采取不同的方法.我想知道是否可以跟踪列表控件中一行的突出显示,而不是跟踪光标.如果我按下向下箭头,则下一行将突出显示,但不会触发NM_CLICK处理程序的执行(这很好).但是,我怀疑某些地方可以突出显示突出显示的代码.不幸的是,我不知道该例程的名称,或者它是否可以被覆盖.我什至不知道该怎么做才能开始尝试为自己找到该信息.我尝试捕获"OnKeyDown",但无济于事.自然,这也在其他地方处理,但是我似乎也无法使代码在那儿中断(这使我相信,它也被跟踪到了我一无所知的第三位.) ,这是维护数百种其他人修改过的代码的乐趣.)我相信我不可避免地会感到绝望.



任何想法都会有所帮助.谢谢.





****************************************************** *******************
原始问题

我正在尝试为列表控件启用WM_HOVER通知(视图=报告").我已经用我能想到的所有方法来搜索它,并且尽管提供了很多链接,但似乎没有人真正指出如何实现此目的.我想知道每次光标在列表中的其他条目上移动,以便向用户显示适当的信息.我拥有的代码没有执行任何操作.

这是我拥有的相关代码:

I suspect my original question (shown below) was faulty. I have discovered that the system I am trying to enhance already tracks the cursor''s movement and I''m pretty sure that leaves me out of the picture. The code is rather massive (upwards of 8 million lines of code) and it is not always immediately evident that what you may be trying to do is already being done some place else. Anyway, I believe I need to take a different approach. Instead of tracking the cursor, I am wondering if it is possible to track the highlighting of a line in a list control. If I hit the down arrow, the next line highlights but does not trigger the execution of the NM_CLICK handler (which is fine). However, I suspect that there is highlighting code somewhere that I may be able to override. Unfortunately, I do not know the name of that routine or if it is something one can override. I don''t even know what to google to begin trying to find that info for myself. I have tried capturing "OnKeyDown" but to no avail. Naturally, that is also being handled somewhere else but I don''t seem to be able to get the code to break there either (which leads me to believe that it is also being tracked in a third place that I know nothing about. Ahhh, the joys of maintaining code that hundreds of others have modified.) I believe I feel the inevitable onset of despair.



Any ideas would be helpful. Thanks.





*********************************************************************
Original question

I am trying to enable WM_HOVER notification for a list control (view = "report"). I have googled this in every way I can think of and while there are plenty of links provided, none seem to actually point to how this can be accomplished. I want to know every time the cursor moves over a different entry in the list so I can present appropriate info to the user. The code I have does nothing.

This is the pertinent code I have:

// DoDataExchange
DDX_Control(pDX, IDC_CATMANAGE_LIST, m_ListCtrl);

// Message Map
ON_NOTIFY(NM_HOVER, IDC_CATMANAGE_LIST,  OnTest)

// OnInitDialog
m_ListCtrl.SetExtendedStyle(m_ListCtrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT);

DWORD dwTime = m_ListCtrl.GetHoverTime();
if (dwTime == -1)
	m_ListCtrl.SetHoverTime(400);
	
void CCatManage::OnTest(NMHDR* pNMHDR, LRESULT* pResult)
{
    int k=0;   // set break point here just to see if we ever get here
}

推荐答案

我正在重写答案:
仍然不是它和MFC的答案,但是您可以找到一条出路,

为了将鼠标悬停在此扩展样式上,请执行以下操作:
I am rewriting the answer:
Still its not and MFC answer, but you can get a way out,

to get on mouse over set this extended style:
int estyle=LVS_EX_TRACKSELECT ;
ListView_SetExtendedListViewStyle(hListView,estyle);



它具有命中测试功能(ListView_HitTest),您可以使用它来确定它的悬停位置.您可以在NM_HOVER上对其进行处理



It has hit test function (ListView_HitTest), you can use this to figure out where it is hovering. You can process it on NM_HOVER


我最初的尝试非常正确(谈论运气!).我所做的更改是用LVN_HOTTRACK代替NM_HOVER.每次光标进入ListControl面板时,这将使处理程序获得控制权.但是,我仍然遇到问题. MFC文档说lParam指向NMLISTVIEW结构,但是我发现它似乎是wParam值指向NMLISTVIEW结构.

所以代码是:

My original attempt was very close to correct (talk about blind luck!). The change I made to make this work was substituting LVN_HOTTRACK for NM_HOVER. This causes the handler to get control every time the cursor enters the ListControl panel. However, I still ran into a problem. The MFC documentation says that the NMLISTVIEW structure is pointed to by the lParam but I have found that it seems to be the wParam value that points to the NMLISTVIEW structure.

So the code is:

// DoDataExchange
DDX_Control(pDX, IDC_CATMANAGE_LIST, m_ListCtrl);

// Message Map
ON_NOTIFY(LVN_HOTTRACK, IDC_CATMANAGE_LIST,  OnTest)

// OnInitDialog
m_ListCtrl.SetExtendedStyle(m_ListCtrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_TRACKSELECT);

void CCatManage::OnTest(NMHDR* pNMHDR, LRESULT* pResult)
{
    int	k;
    NMLISTVIEW *lpnmlv;

    lpnmlv = (LPNMLISTVIEW) pNMHDR;
    k=0;   // set break point here to check the iItem value of lpnmlv
}


这篇关于CListCtrl中的曲目选择(或悬停)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆