problem setting the mouse cursor on a view
-
Hi, I'm working on a multi-view application and I'm trying to change the mouse cursor when it is moved over one of the views. I've got the following code in the view: BOOL CTheView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { ::SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(m_mouseCursor))); return TRUE; //Handled } I'm doing it this way since I've disabled the class cursor with: ::SetClassLong(this->GetSafeHwnd(), GCL_HCURSOR, NULL); and initialised the m_mouseCursor attribute with the appropriate system cursor type. [This appears to work since a later attempt to GetClassLong(GCL_HCURSOR) returns NULL.] However, when I drag the mouse over the view, I get the required cursor flickering with the standard mouse cursor. When the mouse stops moving, the standard mouse cursor is the one displayed. This eliminates the cause being an incorrect cursor id, since the correct cursor actually appears, but overwritten shortly after. I suspect the problem to be due to the fact that I have a number of views in my application, but the cause is unfortunately not clear. If anyone can shed any light on this, your help will be much appreciated.
-
Hi, I'm working on a multi-view application and I'm trying to change the mouse cursor when it is moved over one of the views. I've got the following code in the view: BOOL CTheView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { ::SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(m_mouseCursor))); return TRUE; //Handled } I'm doing it this way since I've disabled the class cursor with: ::SetClassLong(this->GetSafeHwnd(), GCL_HCURSOR, NULL); and initialised the m_mouseCursor attribute with the appropriate system cursor type. [This appears to work since a later attempt to GetClassLong(GCL_HCURSOR) returns NULL.] However, when I drag the mouse over the view, I get the required cursor flickering with the standard mouse cursor. When the mouse stops moving, the standard mouse cursor is the one displayed. This eliminates the cause being an incorrect cursor id, since the correct cursor actually appears, but overwritten shortly after. I suspect the problem to be due to the fact that I have a number of views in my application, but the cause is unfortunately not clear. If anyone can shed any light on this, your help will be much appreciated.
My first guess is you're calling the global scope SetCursor function and you need to call the one that is a member of your window. Remove the :: and see what happens. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff.
-
My first guess is you're calling the global scope SetCursor function and you need to call the one that is a member of your window. Remove the :: and see what happens. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Thanks Christian, It wasnt that. It turned out to be a silly error. Another place in the code was calling BeginWaitCursor() EndWaitCursor(). Turns out EndWaitCursor() simply resets the cursor to the standard arrow cursor, not to the previous cursor as would be logical.