绘制鼠标指针图标? [英] Draw mouse pointer icon?
问题描述
我正在编写有趣的小工具.我希望能够在与原始鼠标不同的位置绘制第二个(或更多个)鼠标指针图标,但要根据原始鼠标的移动来移动它.
I am coding little fun gadget. I want to be able to draw second (or more) mouse pointer icons at different location than the original mouse but to move it according to move of original mouse.
我知道如何跟踪鼠标的移动,但是我不知道如何绘制/重新绘制鼠标指针;有人可以帮忙吗?
I know how to track movement of the mouse but I dunno how to draw/redraw mouse pointer; can anyone help?
推荐答案
可以这样做:
grab the current mouse cursor from your application, using
LoadCursor()
. Just specify NULL, and the cursor you want. Or just load a bitmap for the cursor. Now, you have a bitmap.
Next step is to get the Device context of your Desktop: GetWindowDC(NULL)
. This will give you the opportunity to draw on the desktop anywhere.
您很有可能需要申请 CreateCompatibleBitmap()
到#1处的图片,并在#2处获得DC.
There is a huge chance that you will need to apply CreateCompatibleBitmap()
to the Image at #1 with the DC obtained at #2.
现在,使用一些 BitBlt()
从要放置光标的位置将#2处获得的DC中的OUT位复制到保存图像中(您将需要创建这些图像).
Now, use some BitBlt()
to copy bits OUT from the DC obtained at #2 into a save image (YOU will need to create these) from the position you want to put your cursor.
现在,将在#3处获得的图像放在所需位置的在#2处获得的桌面的DC上.
Now, put the image obtained at #3 onto the DC of the Desktop obtained at #2 at the position you want.
当用户移动鼠标时,使用保存在#4处的数据将图像恢复到桌面上.释放所有不需要的东西(是的,这是强制性的).
When the user moved the mouse restore the image on the desktop with the saved data at #4. Release all the stuff you don't need (yes, this is mandatory).
然后从#1重新开始.
另外两个链接可能会有所帮助:
These two more links might help:
祝你好运!
这篇关于绘制鼠标指针图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!