In my prog i load a cursor (little hand) from a resource file and for the most part it works fine. The problem is when i move it over a button i made with CreateWindowEx it will default back to standard windows arrow, ( just as it does when using the menu but thats not a problem). Since this window is my "game in eternal progress " program, i would want it to do just the opposite. I want the hand cursor to only appear when over a button or something of significance. I believe i posted this same problem some time ago and it went merrily down the list into oblivion. Any help is appreciated.

thanx :alright:
Posted on 2002-06-02 15:11:08 by titan
There is a chance that your parent window gets a WM_SETFOCUS message from button control. Returning 1 should prevent the control from f?rther processing this message, but I havent tested that.

Posted on 2002-06-02 15:21:39 by japheth
Look into WM_SETCURSOR. From my understanding, this message is posted to your parent window by the button when the mouse enters. If you return TRUE it (the button) should leave the cursor alone. Otherwise it'll change it as you've described


ParentWindow PROC hWin,uMsg,lParam,wParam:DWORD
je @@SetCursor
invoke DefWindowProc,hWin,uMsg,lParam,wParam
mov eax,TRUE
ParentWindow ENDP

Posted on 2002-06-02 15:28:32 by chorus
oh yes, I meant WM_SETCURSOR, not WM_SETFOCUS of course :grin:
Posted on 2002-06-02 15:36:04 by japheth
your gonna have to subclass your button to intercept the WM_SETCURSOR message. should look similar to this:
subButton Proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

invoke SetCursor,hCur1
invoke CallWindowProc, OldButtonProc, hWin, uMsg, wParam, lParam
subButton endp

load your new cursor in the WM_CREATE
Posted on 2002-06-02 16:03:47 by smurf
You shouldn't have to subclass. The API says:

The DefWindowProc function passes the WM_SETCURSOR message to a parent window before processing. If the parent window returns TRUE, further processing is halted.

so long as your button is a child of your own window, it should pass the message to that window. You can process the message there and return TRUE. When the child gets the message back, it'll stop executing it's own WM_SETCURSOR instead of going on and changing the cursor.

Posted on 2002-06-02 16:35:15 by chorus
If the parent window returns TRUE, further processing is halted.

what good will that do? the cursor will stay the same throughout the window and child windows. he's dealing with two different cursors: the one his parent window will have(default cursor) and then what the button will have(hand cursor). he's going to need to process the message separately from the parent window.

have you tested your method? it bet your life t wont work.
Posted on 2002-06-02 17:17:21 by smurf
Actually, just looking at his post he says the hand cursor is the default cursor for his parent window (or, at the very least, that's what he implies). Then he says his problem is that the button changes the cursor from the hand cursor to the default cursor. And that's the problem that my solution is for :)

However, the rest of the post kinda contradicts itself... I'm not sure why he is loading the Hand cursor to the window in the first place if he wants the default cursor. In this case, smurf, I see what you mean. He should load the default cursor to the parent window and subclass the button.

Of course, Titan, if you are doing this for many buttons you're probably gonna end up superclassing it...

Oh, and no, I didn't test my method. It will work for what I was intending it to work for. I just intended the wrong thing.

Posted on 2002-06-02 17:43:16 by chorus
Here is what i tried

invoke LoadCursor,hInstance,IDC_1 ;(my hand cursor)

ret TRUE

What happens now is the default cursor (Windows arrow) is there permanently whether over a button or not. My hand cursor does not appear at all.
Posted on 2002-06-02 20:16:14 by titan
hi titan,

i posted a solution already. look at my above post. with your latest attempt all your trying to do is override your main windows default icon. to do that all you need to do is set your cursor when you first call loadcursor right before you register your window.

invoke invoke LoadCursor, hinstance,IDC_1
mov wc.hCursor, eax,
Posted on 2002-06-02 20:39:24 by smurf