Thread: Loading Different curors

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    112

    Loading Different curors

    Hey, I'm trying to use a different cursor but whenever the cursor is over a control it goes back to the normal arrow. My code is posted below.

    Code:
    case WM_MOUSEMOVE: 
    POINT mousePos;
    
    mousePos.x= LOWORD(lParam); 
    mousePos.y = HIWORD(lParam);
    if(mousePos.x >= 10 && mousePos.x <= 482)
    	SetCursor(LoadCursor(NULL, IDC_HAND));
    break;
    Also how can I get the mousePos.x and mousePos.y to change when its over a control?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    try
    Code:
    HCURSOR   Hand=NULL;
    
    Hand=LoadCursor(NULL,(IDC_HAND));
    SetClassLong(hWnd,GCL_HCURSOR,(long)Hand);
    SetCursor(Hand);
    use GetWndowRect() on ctrl, then test if over crtl with PtInRect() using the ctrls window rect and the mouse POINT.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    I've tried sort of the same thing but the problem is that the WM_MOUSEMOVE message is only sent when the mouse is on the dialog. So If the mouse is over a button I don't know its coordinates and can't tell if its in the buttons rect.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I don't fully understand what you want. If you are trying to tell if the user tries to push a button on ANOTHER app and stop them, why?

    otherwise look at

    SetCapture() or WM_NCMOUSEMOVE//non client is menu, border and title of dlg, not 'outside' of dlg.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    I think, you can use SetCursor () only when the window class (of the control, used on the control creation) has NULL in hCursor member. New window procedure for that control can use SetCursor () eventually.

    Another solution:

    Use GetClassInfo (), derive new window class using the old control window class. Set hCursor to your favourite cursor shape, then create the control with this new class. It should work.

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    novacain, what you said in your first post works except for when the mouse goes over a control. What I want to do is have my mouse cursor change to the hand when its over a certain button. The two problems I have been haveing is that WM_MOUSEMOVE is not sent when the cursor is over a control and the mouse cusor does not change when its over a control.

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    13
    A WM_MOUSEMOVE message should be sent to the control that the mouse is over in the case you're describing.... remembering, Windows controls are actually windows themselves...

    I'm not sure how you would catch the message that gets sent to the control tho, I've never tried to do that before.

    Edited because the spelling fairy forgot to visit me when I was growing up...

  8. #8
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>I'm not sure how you would catch the message that gets sent to the control tho,
    it should be sent to the parents callback. (the HWND_PARENT supplied in creation)

    Try
    SetCapture(hWndButton)
    should then provide you with the msgs you need

    If I have time I will look further but I use frame ctrls as 'hot spots' on images for similar purposes.

    Only the foreground window can capture mouse input so if the button does not have focus may not generate mouse move msgs.
    Last edited by novacain; 05-20-2002 at 10:32 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cargo loading system
    By kyle rull in forum C Programming
    Replies: 1
    Last Post: 04-20-2009, 12:16 PM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  4. need help with .md3 file loading
    By Shadow12345 in forum Game Programming
    Replies: 2
    Last Post: 12-06-2002, 04:06 PM
  5. Loading Screen
    By pinkcheese in forum Windows Programming
    Replies: 2
    Last Post: 04-06-2002, 11:48 PM