Consider my code below Cursor m_OldCursor; void OnCursorChanged(object sender, EventArgs e) { if(m_OldCursor != null) { m_OldCursor.Dispose(); } m_OldCursor = new Cursor(this.Cursor.CopyHandle()); } void ProcessMouseMove(EventArgs e) { // m_OldCursor is used here too. // hence cannot be declared everytime in // OnCursorChanged. }
I know it is wrong to use a object after it is disposed. but every single time the CopyHandle() method is invoked, it creates a handle. since there is a restriction on the number of handles that windows can manage, i need to dispose this handle after its use. if not then the application will crash. If instead of Cursor, it was a control then i could have used the DestroyHandle property. Could you suggest me any other way to do the same. thanks in advance.
Keshav Kamat :) India