Click to See Complete Forum and Search --> : Wait cursor in dialog


ZM73
April 1st, 1999, 05:02 PM
How to displaying the hourglass cursor during some lengthy processing of a command handler implemented in dialog base application.
I've tried the BeginWaitCursor command, but like MSDN explain, the dialog box normally change the cursor to the standard arrow cursor, and leave the cursor in as the standard arrow cursor.

Alvaro
April 1st, 1999, 05:25 PM
The nicest way is to use CWaitCursor, like this:

void CMyDlg::OnLengthyOperation()
{
CWaitCursor wait; // set wait cursor

....
} // restore cursor (on destruction)


Alvaro

Oak
April 9th, 1999, 02:03 PM
The point is that there is function
OnSetCursor and each time u move mouse it restores old cursor. To prevent that u need:
1st: set wait cursor by
m_hCurrentCursor = AfxGetApp()->LoadStandardCursor(IDC_WAIT));
SetCursor(m_hCurrentCursor);

2nd: Overwrite function OnSetCursor in ur dialog or not dialog based application and put there code:

BOOL CUrViewOrDialog::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default


SetCursor(m_hCurrentCursor);
return TRUE;

//return CScrollView::OnSetCursor(pWnd, nHitTest, message);
}

When u need to set old cursor place next code:
m_hCurrentCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
SetCursor(m_hCurrentCursor);

WBR Oak