Register  ::  Login

February 06, 2012

Forums
 
Subject: Change Cursor
Prev Next

Author Messages
DonUser is Offline
New Member
New Member
Posts:20


01/30/2005 5:20 PM Quote Reply  

From the Borland non-technical forum:


>
> Jon Shemitz wrote:
>
> > A better solution would involve a simple IDisposable wrapper class,
> > and 'using'.
>
> Could you show us an example Jon?

public class PushCursor: IDisposable {

public PushCursor(Control C, Cursor NewCursor) {
this.C = C;
OldCursor = C.Cursor;
C.Cursor = NewCursor;
}

private Control C;
private Cursor OldCursor;

#region IDisposable Members

public void Dispose() {
C.Cursor = OldCursor;
}

#endregion
}

// which is more code than you show, but you
// only have to write it once, and then just say

using (new PushCursor(this, Cursors.WaitCursor)) {}

// doesn't always set back to Cursors.Default, can be nested, &c.



Quick Reply
Username:  
Subject:  
Body: