删除后CVSListBox通知
我刚刚将新的(MFC 功能包)CVSListBox 控件之一添加到项目中。 控件中的项目列表由应用程序中的一些其他对象跟踪,因此当发生任何更改时,我需要从列表框中获取大量通知,以便我可以更新其他内容。 对于那些不了解该控件的人,有一个按钮栏提供基本的添加/删除/重新排序功能。
CVSListBox 控件提供了可重写的虚拟函数,用于添加或重命名项目以及更改其顺序 - 所有这些都运行良好。
然而,对于删除项目,唯一的替代是 OnBeforeRemoveItem,它在删除项目之前调用,并且必须返回 TRUE/FALSE 才能允许删除。 删除后,不会有任何具体通知。
删除后获取通知的最佳方式是什么?
显然,这里可能会发生一些可怕的事情,因为删除后将出现选择更改事件,并且可以保留删除前的标志来表示下一个选择更改是特殊的。 但我觉得我错过了一些更干净、更明显的东西。 有什么建议么?
I've just added one of the new (MFC Feature Pack) CVSListBox controls to a project. The list of items in the control is tracked by some other objects in my application, so I need to take lots of notifications from the list-box when anything changes so that I can update other stuff. For those that don't know the control, there is a button bar which offers basic add/delete/reorder functionality.
The CVSListBox control offers overridable virtual functions for things like adding or renaming items, and changing their order - all this works nicely.
However, for deleting items, the only override is OnBeforeRemoveItem, which is called BEFORE an item is removed, and from which one has to return TRUE/FALSE to permit the remove. Once the remove has occurred, there's no specific notification.
What's the best way to get notification AFTER a remove?
Obviously it's possible to hack something horrible here, in that there will be a selection-changed event after a remove, and it would be possible to hold a flag from the before-remove to say that the next selection-changed is special. But I feel like I'm missing something cleaner and more obvious. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这样的事情:
希望有帮助。
Try something like this:
Hope it helps.
假设该项目每次都会真正被删除,您可以:
Assuming that the item will truly be removed every time, you could either: