如何禁用从 Rich Edit 控件拖动
我使用 CRichEditCtrl 的子类来提供 CEdit+ 类型控件。我想要的一件事是禁用拖放功能,这是基类默认提供的。
禁用拖放很容易: ::RevokeDragDrop(m_hWnd);
但我看不到禁用控件作为拖动源的简单方法。有简单的方法吗?
I use a subclass of CRichEditCtrl to provide a CEdit+ type control. One thing I want is to disable drag-drop functionality, which the base class provided by default.
Disabling dropping is easy: ::RevokeDragDrop(m_hWnd);
But I can't see a simple way to disable the control being a drag-source. Is there an easy way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要覆盖
RichEdit
控件中的启动拖放操作:IRichEditOleCallback
接口。GetDragDropEffect()
方法,如下所示:这里最重要的是
return E_ABORT;
这会导致退出默认拖放操作并启动自定义拖放操作。要覆盖
RichEdit
控件中的接收拖放操作:IDropTarget
接口。IDropTarget
接口如下:在
RichEdit
派生子类函数中创建RichEdit
控件后:本示例覆盖
RichEdit的默认放置目标函数
。To Override Starting Drag-and-Drop in the
RichEdit
Control:IRichEditOleCallback
interface.GetDragDropEffect()
method of the interface like this:Most important here is
return E_ABORT;
this causes quitting default drag and drop operation and starting the customized one.To Override Receiving Drag and Drop Operation in the
RichEdit
Control:IDropTarget
Interface.IDropTarget
interface like this:After Creating
RichEdit
control inRichEdit
derived subclass function:This example overrides the default drop target function of
RichEdit
.警告:我远离我的编译器,所以我无法检查这一点。
我也想不出一个简单的方法,但是......
这是一篇关于扩展文本控件以支持拖动的文章。
http://www.code-magazine.com/article。 aspx?quickid=0407031&page=5
是的,这与您想要的完全相反。
但请考虑,它是关于检测指示您要启动拖动操作的鼠标消息。如果您的子类执行了此操作,然后不让 CRichEditCtrl 获取触发拖动的窗口消息,则拖动将不会开始。
可能有用。
Caveat: I'm away from my compiler, so I can't check this.
I can't think of a simple way either, but ...
This is an article about extending a text control to support dragging.
http://www.code-magazine.com/article.aspx?quickid=0407031&page=5
Yes, it's the exact opposite of what you want.
But consider that it's about detecting the mouse messages that indicate that you want to initiate a drag action. If your subclass did this, and then just didn't let the CRichEditCtrl get the window message(s) that triggers the drag, the drag wouldn't start.
Might work.