I am using a PNG image as a cursor by translating the image with the mouse coordinates and it moves very nice. The problem is when I tried to click a button, for some reason the button flashes as I move the mouse over it. The button goes inactive or not focused and mouse clicks are not working until for some fraction of a second where if I keep moving the mouse and clicking over the button, then the mouse click works. I tried also to play with the z-index having no results.
When I tried the hidden cursor without the image, the mouse events works without problems. This is the code I am using:
TranslateTransform T = new TranslateTransform();
public GameTitle()
{
InitializeComponent();
Mouse.OverrideCursor = Cursors.None;
this.MouseMove += GameTitle_MouseMove;
CompositionTarget.Rendering +=CompositionTarget_Rendering;
}
void CompositionTarget_Rendering(object sender, EventArgs e)
{
CursorImage.RenderTransform = T;
}
void GameTitle_MouseMove(object sender, MouseEventArgs e)
{
T.X = e.GetPosition(this).X;
T.Y = e.GetPosition(this).Y;
}
This is with the image cursor:
And this is without the image cursor and the mouse cursor hidden:
How can I make the buttons works with the image cursor? Thanks in advance for your help!