组合框中的热跟踪列表项目选择 [英] Hot tracking list item selection in a combo box
问题描述
我有一个组合框,我需要拦截选择的更改,而用户更改选择只需用鼠标悬停鼠标而不用点击。这是用于显示有关用户悬停在其上的项目的补充信息。
CBN_SELCHANGE
不会执行此作业,因为只有当用户通过点击其中一个组合框项目或按下向上/向下键来更改选择时,此消息才会触发。
显然,当用户将光标悬停在组合框上时,不会触发任何消息。
插图 b
$ b
例如:我需要知道用户何时将鼠标从条目 2
移动到条目 33
。
这是基于 这是在Windows 10上测试的。 这只能在下拉列表中报告悬停选择,它不能更改选择。 I have a combo box and I need to intercept the changement of the selection while the user changes the selection by just hovering with the mouse without clicking. This is for displaying complementary information about the item the user is hovering over. Apparently no message is fired while the user is just hovering over the the combobox. Illustration E.g: I need to know when the user moves the mouse from the entry This is c++ subclass based on c# article which you mentioned: This was tested on Windows 10. This can only report the hover selection in drop down list, it can't change the selection. 这篇关于组合框中的热跟踪列表项目选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
LRESULT CALLBACK ComboProc(HWND hwnd,UINT msg, WPARAM wParam,
LPARAM lParam,UINT_PTR uIdSubClass,DWORD_PTR)
{
if(msg == WM_CTLCOLORLISTBOX)
{
COMBOBOXINFO ci = {sizeof(COMBOBOXINFO)};
GetComboBoxInfo(hwnd,& ci);
if(HWND(lParam)== ci.hwndList)
{
int pos = SendMessage(ci.hwndList,LB_GETCURSEL,0,0);
OutputDebugStringA(std :: to_string(pos).c_str());
OutputDebugStringA(\\\
);
}
}
if(msg == WM_NCDESTROY)
{
RemoveWindowSubclass(hwnd,ComboProc,uIdSubClass);
}
return DefSubclassProc(hwnd,msg,wParam,lParam);
}
...
SetWindowSubclass(hComboBox,ComboProc,0,0);
CBN_SELCHANGE
won't do the job, because this message gets fired only when the user has actually changed the selection by clicking on one of the combo box items or when the up/down keys are pressed.2
to the entry 33
.LRESULT CALLBACK ComboProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubClass, DWORD_PTR)
{
if (msg == WM_CTLCOLORLISTBOX)
{
COMBOBOXINFO ci = { sizeof(COMBOBOXINFO) };
GetComboBoxInfo(hwnd, &ci);
if (HWND(lParam) == ci.hwndList)
{
int pos = SendMessage(ci.hwndList, LB_GETCURSEL, 0, 0);
OutputDebugStringA(std::to_string(pos).c_str());
OutputDebugStringA("\n");
}
}
if (msg == WM_NCDESTROY)
{
RemoveWindowSubclass(hwnd, ComboProc, uIdSubClass);
}
return DefSubclassProc(hwnd, msg, wParam, lParam);
}
...
SetWindowSubclass(hComboBox, ComboProc, 0, 0);