Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have an application whose UI is custom rendered with a theme. I also want to add new non-default-cursors (like the resize cursors when the user intends to resize the window) to match that theme.

With the WinAPI function SetCursor I am only able to change the default pointer for the application, but this is not enough, so I looked up SetSystemCursor which works just fine. Problem is: The latter version changes the cursors system-wide permanently, but I only want them to be changed for my application only.

I thought about copying the previous cursors before I do the SetSystemCursor and re-set them at application exit, but even when I implement a terminate handler it may not be called if the process e.g. just crashes. Also the cursors would still be changed system-wide as long as the application is running.

Specifically for the resize-cursors, I could just drop the window style, make a borderless window, and render/implement the resizing grips and logic myself (then I could just hook the mouse-over events), but that is really just my last resort - I'd rather like to know if it is possible achieve my goal before I do this cumbersome task...

For anyone who is interested: The UI is rendered with WPF, but WPF doesn't provide this functionality either (again, they have it, but just for the default pointer). It's no concern for me to use the WinAPI or other "low-level" calls if I have to, but at the moment it seems there are none that are fitting my needs :(

So if anybody knows how to change the other system cursors (not the default pointer) in WPF or WinAPI just for my application without having to implement custom cursor-logic to my window just for that, you would make my day.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
191 views
Welcome To Ask or Share your Answers For Others

1 Answer

I don't know how to implement this in WPF, but if you want to set the cursor to something other than default, then your window procedure should handle the WM_SETCURSOR message.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms648382(v=vs.85).aspx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...