Home >Backend Development >C++ >`Cursor.Current` vs. `this.Cursor` in .NET: What's the Difference and When Should I Use Each?
Cursor.Current vs. this.Cursor in .Net
When working with cursors in .Net, there are two commonly used properties: Cursor.Current and this.Cursor. It's natural to wonder if there is any difference between these properties.
Cursor.Current vs. this.Cursor
When to Use
Gotcha with Cursor.Current
As mentioned in the referenced code示例, setting Cursor.Current may not always result in the desired behavior. This is because the system sends the WM_SETCURSOR message to the window containing the mouse cursor, which can override the cursor shape set by Cursor.Current.
How to Display Hourglass Cursor Properly
To display an hourglass cursor correctly, you should use both Cursor.Current and Application.UseWaitCursor properties. You can also use a helper class like the HourGlass class provided in the referenced answer to simplify this process.
In summary, Cursor.Current changes the cursor shape globally, while this.Cursor changes it for a specific control. Use the appropriate property based on the scope of the cursor change you want to achieve.
The above is the detailed content of `Cursor.Current` vs. `this.Cursor` in .NET: What's the Difference and When Should I Use Each?. For more information, please follow other related articles on the PHP Chinese website!