Mouse button click changing my loaded cursor - Programmer

This is a discussion on Mouse button click changing my loaded cursor - Programmer ; In a MFC SDI, I maintain a list of CRect's that represent hot spots on the display. In the MyCView::OnMouseMove() event, I loop through all the rectangles looking for a TRUE return from CRect::PtInRect(..). When found, I change the cursor ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Mouse button click changing my loaded cursor

  1. Mouse button click changing my loaded cursor

    In a MFC SDI, I maintain a list of CRect's that represent hot spots on
    the display. In the MyCView::OnMouseMove() event, I loop through all
    the rectangles looking for a TRUE return from CRect::PtInRect(..).
    When found, I change the cursor to a pointing finger. No problems
    here...works fine.

    Thing is, if I click the mouse button when over any of these hot spots
    (LClick, RClick, Double clicks, doesn't matter), something (internal)
    changes the mouse cursor back to the standard IDC_ARROW.

    I've tried overriding and nulling out the button up/down messages,
    thinking that the default implementation is doing it, but to no avail.

    Any ideas?

    Thanks for you feedback.

  2. Re: Mouse button click changing my loaded cursor

    you need to catch the WM_SETCURSOR message in your window. And call
    SetCursor in there.

    Here it is:

    class CMyWnd : public CWnd
    {
    ....
    HCURSOR m_Cursor;
    ....
    }

    void CMyWnd::OnMouseMove(...)
    {
    if (InHotSpot)
    {
    m_Cursor = LoadCursor(NULL,IDC_HAND);
    }
    else
    {
    m_Cursor = LoadCursor(NULL,IDC_ARROW);
    }
    }

    BOOL CMyWnd::OnSetCursor(...)
    {
    SetCursor(m_Cursor);
    return FALSE;
    }

    Ali R.

    "RWey" wrote in message
    news:ecb995af.0310080945.1608882a@posting.google.c om...
    > In a MFC SDI, I maintain a list of CRect's that represent hot spots on
    > the display. In the MyCView::OnMouseMove() event, I loop through all
    > the rectangles looking for a TRUE return from CRect::PtInRect(..).
    > When found, I change the cursor to a pointing finger. No problems
    > here...works fine.
    >
    > Thing is, if I click the mouse button when over any of these hot spots
    > (LClick, RClick, Double clicks, doesn't matter), something (internal)
    > changes the mouse cursor back to the standard IDC_ARROW.
    >
    > I've tried overriding and nulling out the button up/down messages,
    > thinking that the default implementation is doing it, but to no avail.
    >
    > Any ideas?
    >
    > Thanks for you feedback.




  3. Re: Mouse button click changing my loaded cursor

    Thanks Ali.

    That did the trick. I'm a little new to some of this but manage to
    trudge my way through it

    "Ali R." wrote in message news:...
    > you need to catch the WM_SETCURSOR message in your window. And call
    > SetCursor in there.
    >
    > Here it is:
    >
    > class CMyWnd : public CWnd
    > {
    > ....
    > HCURSOR m_Cursor;
    > ....
    > }
    >
    > void CMyWnd::OnMouseMove(...)
    > {
    > if (InHotSpot)
    > {
    > m_Cursor = LoadCursor(NULL,IDC_HAND);
    > }
    > else
    > {
    > m_Cursor = LoadCursor(NULL,IDC_ARROW);
    > }
    > }
    >
    > BOOL CMyWnd::OnSetCursor(...)
    > {
    > SetCursor(m_Cursor);
    > return FALSE;
    > }
    >
    > Ali R.


  4. Re: Mouse button click changing my loaded cursor

    RWey wrote:

    > Thing is, if I click the mouse button when over any of these hot spots
    > (LClick, RClick, Double clicks, doesn't matter), something (internal)
    > changes the mouse cursor back to the standard IDC_ARROW.


    Handle the WM_SETCURSOR message.

    Jussi Jumppanen
    Author of: Zeus for Windows (All new version 3.90 out now)
    "The C/C++, Cobol, Java, HTML, Python, PHP, Perl programmer's editor"
    Home Page: http://www.zeusedit.com

+ Reply to Thread