bucherren
bucherren

Reputation: 299

How to change the cursor before a long task?

I want to change the cursor before a long task. I changed it with setcursor, but the cursor didn't change.

Here is my code:

    HCURSOR hWait  =  AfxGetApp()->LoadStandardCursor(IDC_WAIT) ;
    HCURSOR hDefault = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
    ::SetCursor(hWait);

    //a long procedure

    ::SetCursor(hDefault);

What am I doing wrong?

Upvotes: 1

Views: 552

Answers (1)

MikMik
MikMik

Reputation: 3466

A very handy way of doing it is by creating an instance of CWaitCursor at the start (or just before) of the long task. It sets the cursor and when it goes out of scope it restores it (in the destructor):

{
    CWaitCursor wait;  

    // Long task

} // The cursor is restored here

Upvotes: 1

Related Questions