如何将鼠标悬停在放置目标时更改拖拽光标鼠标、光标、如何将、拖拽

2023-09-06 06:58:15 作者:我不会哭因为睫毛膏太贵了

我有一个应用程序,采用了放置目标来解除存档(文件属性)的文件。我想改变鼠标光标形式的DragEnter事件到自定义光标(.CUR),我有作为嵌入资源。

I have an app that incorporates a drop target to unarchive (file attribute) files. I would like to change the mouse cursor in the DragEnter event of the form to a custom cursor (.cur) that I have as an embedded resource.

的放置目标是用目标的图像的透明的形式。 (整个形式是放置目标)

The drop target is a transparent form with an image of a target. (The entire form is the drop target)

我知道我可以使用GiveFeedback事件时,我有拖动源的控制权。然而,这不是这种情况作为源是Windows资源管理器。 (也许我错了,我仍然可以使用GiveFeedback在此方案中,但我无法弄清楚如何触发事件。)

I know I can use the GiveFeedBack event when I have control of the drag source. However this is not the case as the source is Windows explorer. (and maybe I'm wrong and I can still use GiveFeedBack in this scenario, but I could not figure out how to trigger the event.)

要消除我的自定义光标无效或损坏的可能性,我成功设置自定义光标在放置目标形式的鼠标悬停事件。

To eliminate the possibility that my custom cursor was not valid or corrupt, I successfully set the custom cursor in the MouseOver event of the drop target form.

在功能一切正常,我现在只是想pretty的事情了一点点。

Functionally everything is working, I am now just wanting to "pretty things up" a little bit.

在此先感谢任何见解。

推荐答案

您似乎已经知道,自定义光标,设置在GiveFeedback在,如何做到这一点。然后的问题是,你没有得到任何GiveFeedback在事件。我不知道什么控制你有降点,但尝试连接一个监听到底层表的GiveFeedback事件,看看你得到任何反馈那里。

You seem to know already that custom cursors are set in GiveFeedBack and how to do that. The problem then is that you are not getting any GiveFeedBack events. I don't know on what control you have a drop spot, but try attaching a listener to the underlying Form's GiveFeedBack event, and see if you get any feedback there.

您也可以尝试继承您使用的是(面板,图片框或其他),并听取其GiveFeedback事件的控制。

You can also try subclassing the control you are using (Panel, PictureBox or whatever) and listening to its GiveFeedBack event.