Reputation: 5917
I have a process A, that launches a process B. I load a mouse cursor in A, and I want A to change the mouse cursor when the mouse is on the B window. Is it possible?
I tried to call SetCursor from A when the mouse is over B, but even if I handle the WM_SETCURSOR message in B, the cursor never changes. Am I missing something?
Upvotes: 1
Views: 3629
Reputation: 490178
You can change the child process' default cursor using SetClassLong
with GCL_HCURSOR
. This won't affect what's displayed when the child uses SetCursor
to explicitly change its own cursor though, just the default that's displayed when it hasn't specified anything else. Warning: it's possible that a program may never display its default cursor at all, in which case this won't have any effect.
Upvotes: 1
Reputation: 613013
Applications are in control of their own cursors. Calling SetCursor()
cannot from A cannot possibly work. Notice that SetCursor()
has no parameters specifying which application the change is to be made to. This is because the change is made in the calling application.
You will need to inject code into B to effect the desired change.
Upvotes: 1
Reputation: 7160
The only way a window can control the mouse when it's over another window is by capturing the mouse (see SetCapture), or by setting the system mouse, but I very much doubt you want to do the latter.
Unfortunately capturing the mouse means you get all the mouse events sent to your window rather than theirs, so their GUI is unusable.
The only other solution is API hooking and code injection into B where you manage any messages such as WM_MOUSEMOVE and call SetCursor from within the application itself, possibly using some method of interprocess communication to get what cursor to set from application A.
Upvotes: 2