How to change the mouse cursor?
Submitted by date of submission user level
Mahesh Chand Beginner
You can override the CWnd::OnSetCursor() function to change mouse pointer in your application. Call Windows API SetCursor() function to change the pointer.
BOOL CMyView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (m_ChangeCursor)
{
RestoreWaitCursor();
return TRUE;
}
return CView::OnSetCursor(pWnd, nHitTest, message);
}
2. If you want only wait cursor then BeginWaitCursor and EndWaitCursor functions are easy to use. Call BeginWaitCursor() at the starting of your fucntion and call EndWaitCurson when you are exit that function.
void CMyView::PerformLengthyOperation()
{
BeginWaitCursor(); // or AfxGetApp()->DoWaitCursor(1)
//...
EndWaitCursor(); // or AfxGetApp()->DoWaitCursor(-1)
}
NOTE: Use other method if you want other cursors instead of wait cursor.
That's it.
Source: MSDN