C# changing cursor even when the cursor is outside the Form

纵然是瞬间 提交于 2020-05-09 16:48:22

问题


is it possible to change the cursor even when the cursor is at outside of the form?

I used MouseHook by using Win32 API to capture the location of the Cursor when it is outside the form. However, I cannot change the cursor...


回答1:


Programs decide what the cursor should look like. Most windows ask for the default arrow. But, say, a text box control asks for an I-Beam. A hyperlink control asks for the hand. Etcetera. And if you hover over a window edge of a resizable window then the program asks for one of the resizing cursors. Or a program goes off doing something for a while and asks for the hourglass cursor. Etcetera.

Replacing the cursor is thus fraught with trouble, you cannot make correct cursor choices for another program you know nothing about.

You can technically pinvoke SetSystemCursor() to replace one of the system cursors. But that's very troublesome as well, you won't restore it properly when your program bombs. A reboot is required to fix the problem. Also very detrimental to a user with visual impairments, you'll replace the Extra Large cursors she selected with a puny one.

This needs to be a user selection, they go Control Panel + Mouse to select cursors.




回答2:


Maybe you should with try the events MouseEnter and MouseLeave



来源:https://stackoverflow.com/questions/11520911/c-sharp-changing-cursor-even-when-the-cursor-is-outside-the-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!