拖动列表框通知消息 [英] Draglist box Notification messages

查看:88
本文介绍了拖动列表框通知消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用鼠标重新排序列表框项目.我只使用一个列表框.该对话框也很少有组合框和其他内容,因此列表框是该对话框的子控件.

例如,我可以使用鼠标将item5拖放或移动到列表的第二个位置或任何位置.但是,当我这样做时,我希望我的网格在完成执行该操作的那一刻得到更新.

那是item5移到第二个位置的那一刻,我的网格也应该得到更新.我尝试使用LBN_SELCHANGE,但是它在列表框项重置为新状态之前被调用,因此,尽管函数一旦结束,列表框将显示重新排序,但网格不会更新为新状态.

我看到当它被调用时,列表框仍然处于旧状态,一旦完成,状态就会发生变化.实际上,在这种情况下,LBN功能均无用.我尝试使用所有这些.

我找不到任何显示新列表框状态的通知消息功能,可以在列表项移动到新位置的同时使用它来更新网格.

任何想法,将不胜感激.谢谢.

I am able to re-order my list box items using a mouse. I am only using one listbox. The dialog has few combo boxes and other stuff too, so listbox is a child control of that Dialog.

For example I can drag and drop or move item5 to the 2nd position or to any position in the list using my mouse. However when I do that, I want my grid to get updated, the moment I finish performing that operation.

That is the moment the item5 goes to the second position, my grid should also get updated. I have tried using LBN_SELCHANGE, but it gets called before the listbox items reset to a new state, so the grid doesn''t get updated to the new state although the listbox shows the re-ordering once the function ends.

I see when it gets called the listbox is still in its old state, and once it finishes then the change of state occurs. Actually none of the LBN functions are helpful in this case. I have tried using all of them.

I cant find any notification message function that shows the new list box state, that I can use to update my grid at the same moment as the list items move to a new position.

Any ideas on this will be appreciated. Thanks.

推荐答案

我可以在MFC目录中找到一个类... :)

I could find a class in my MFC directory... :)

class CDragListBox : public CListBox
{
...
public:
  // Called when user releases mouse button to end drag event.
  virtual void Dropped(_In_ int nSrcIndex, _In_ CPoint pt);
...





BOOL CDragListBox::OnChildNotify(UINT nMessage, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
	if (nMessage != m_nMsgDragList)
		return CListBox::OnChildNotify(nMessage, wParam, lParam, pResult);
	ASSERT(pResult != NULL);
	LPDRAGLISTINFO pInfo = (LPDRAGLISTINFO)lParam;
	ASSERT(pInfo != NULL);
	switch (pInfo->uNotification)
	{
	case DL_BEGINDRAG:
		*pResult = BeginDrag(pInfo->ptCursor);
		break;
	case DL_CANCELDRAG:
		CancelDrag(pInfo->ptCursor);
		break;
	case DL_DRAGGING:
		*pResult = Dragging(pInfo->ptCursor);
		break;
	case DL_DROPPED:
		Dropped(GetCurSel(), pInfo->ptCursor);
		break;
	}
	return TRUE;
}


感谢回复Eugen.我发现了同样的事情,所以我要从CDragListBox派生一个类,并用基类实现重写虚拟函数Dropped(),然后在其中添加更新的网格代码.我希望它能起作用.
Thanks for the reply Eugen. I found the same thing so I am deriving a class from CDragListBox and overriding the virtual function Dropped() with the base class implementation and then adding the updating grid code to it once that is done.I hope it will work.


这篇关于拖动列表框通知消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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