How to show a wait cursor

4 02 2009

description1

 

 

It is very useful to show a wait cursor while you are doing a lengthy operation in your application. Otherwise the users may feel anxious with your non-responsible application.

howcanidoit1

 

 

To display a wait cursor, just define a CWaitCursorMFC function – variable before the code that performs the lengthy operation. When the object goes out of scope it will automatically restore the regular cursor.

mycodesnippet1

 

 

void DoSomeLengthyOperations()
{
   CWaitCursor wait;
   //Do some lengthy operations.
   Sleep(1000);
  
   //This changes the cursor.
   AfxMessageBox(_T("Helloooo"));
  
   //Restore the Wait cursor.
   wait.Restore();
  
   //Continue the lengthy operations.
   Sleep(1000);
  
   //Now the cursor back to Regular cursor.   
}

mynote1

 

 

Actually the constructor and destructor of the CWaitCursor function makes the creation and deletion of the wait cursor respectively. So it is better to declare it’s objects as local variables, otherwise you could allocate it by using new operator.

Advertisements

Actions

Information

2 responses

26 06 2012
Ice man

Thanks!

27 06 2012
Sanoop S P

Welcome

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: