Get the current cursor
I have a form in which I change the icon to the cursor to add a certain icon to a TableLayoutPanel, but I can not find a way in which I can get the icon that currently has the cursor, I was reviewing the properties of the Cursor class in C # and there is the Property Cursor.Current that returns an object that represents the current cursor the Cursor.Handle property that gets the identifier of the cursor, I found an example in which it draws the icon in the form, but it does not give me control over said icon so you can add it where you need it
This is my example, in which I want to obtain the cursor and then add it to another control (TableLayoutPanel or another) and not only draw it directly in the form:
SO CHANGE ICON IN THE MENU
Where the click event happens on a button of a custom control in the form of a menu that is displayed when clicking on the add button, there when selecting any icon, the cursor takes its shape and that is where I want to get that icon and paste it in The TableLayoutPanel.
private void pb_individuos_click( object sender, EventArgs e )
{
Icon icono_individuo = Properties.Resources.individuo32;
ParentForm.Cursor = new Cursor(icono_individuo.Handle);
}
INVESTIGATE AND FIND A METHOD, BUT ONLY DRAW IT AND YOU DO NOT OBTAIN IT
void method Cursor.Draw ( Graphics g, Rectangle targetRect) where Graphics is the surface where you are going to draw and Rectangle are the limits:
private void DrawCursorsOnForm( Cursor cursor )
{
if ( this.Cursor != Cursors.Hand &
Cursor.Current == Cursors.Default)
{
// Draw the cursor stretched.
Graphics graphics = this.CreateGraphics();
Rectangle rectangle = new Rectangle(
new Point( 10, 10 ), new Size( cursor.Size.Width * 2,
cursor.Size.Height * 2 ) );
cursor.DrawStretched( graphics, rectangle );
// Draw the cursor in normal size.
rectangle.Location = new Point(
rectangle.Width + rectangle.Location.X,
rectangle.Height + rectangle.Location.Y );
rectangle.Size = cursor.Size;
cursor.Draw( graphics, rectangle );
// Dispose of the cursor.
cursor.Dispose();
}
}
ANOTHER INVESTIGATED EXAMPLE
In this link do something similar in C # in WPF applications: C # get current cursor icon