I have a easy winform with a button on it.
When I press the button, the cursor is like 1ms the cursor I want it to be, but than it instantly changes back to the default cursor.
How can i keep the cursor a cross? (Not only on the form, everywhere on the screen)
private void btn_takeScreenshot_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.Cross;
}
Related
3D buttons aren't a problem. It's the flat buttons (when Button.FlatStyle == FlatStyle.Flat).
I set the background color of the button Color.Black. When I press and hold the left mouse button, the background color changes to a gray color, which I am trying to prevent.
I've tried some Mouse events triggered by the button, especially MouseDown. I've also used the BackColorChanged event and still didn't work.
In short, when the mouse is down, the button is grey. When the mouse is up, the button is black. How do I prevent that? How do I keep the button black?
Changing property Button.FlatAppearance.MouseDownBackColor works like a charm:
private void FocusBtn_MouseDown(object sender, MouseEventArgs e)
{
FocusBtn.FlatAppearance.MouseDownBackColor = Color.Black;
}
Is it possible to detect a click on a picturebox that is not visible
I have tried this :
private void PictureBox1_Click(object sender, EventArgs e)
{
MessageBox.Show("teste");
}
But even if the picture box has no image and that background color is transparent, it hides the elements behind it.
I explain myself a little better;
I do a tic-tac-toe and I have the image of the cross that is not visible when the game is started; as soon as I press on a delimited area (where I want to place the cross), I want it to become visible
How can I do that?
Thank you.
I would use the PictureBox with an ImageList containing 2 images: the first is the background of your game field and the second is the cross.
In your Click Event I would toggle the pictures on click then.
I am using the scroll event but this only update value in label when i click on trackBar and move it right or left. I see that i can move it when i use mouse wheel but this doesn't update value in label just moving it.
private void metroTrackBar1_Scroll(object sender, ScrollEventArgs e)
{
lblVolume.Text = metroTrackBar1.Value.ToString();
}
So my question is:
How I can make trackBar to update value in label when i scroll with mouse wheel?
I found solution, used ValueChanged event instead of Scroll event, this works in both cases, when i move trackBar with mouse wheel or when i drag it with mouse.
private void metroTrackBar1_ValueChanged(object sender, EventArgs e)
{
lblVolume.Text = metroTrackBar1.Value.ToString();
}
Is there a way to hide the mouse cursor in a windows store application in code so that the mouse is hidden immediately on application start?
I run the following command as my page starts and nothing happens until I physically move the mouse. As soon as I move the mouse it hides. If I don't move it it stays on screen indefinitely. As I'm displaying graphics I need to hide the mouse immediately without any input from the user.
Window.Current.CoreWindow.PointerCursor = null;
As Colin mentions in the comments the mouse pointer disappears if you hide it when the window fires the Loaded event.
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
Window.Current.CoreWindow.PointerCursor = null;
Window.Current.CoreWindow.PointerPosition = new Point(42, 42);
}
My problem is the WebView element, it briefly flickers the mouse pointer once when moving it even with this code.
I have a WinForm application that has a panel and two buttons inside the panel. I added a mousemove event on my panel and the mousemove function gets called when I move the mouse inside my panel, just like expected.
The problem is, if I press down my mouse button while over a button, the button depresses and if I move my mouse into the panel while still holding down the button, the Panel mousemove function never gets called till I release the mouse button.
Is there a work around for this? And if I'm not being clear, I can try to be more clear.
So it seems that while the button is depressed and the mouse moved back over the underlying panel, the panel's MouseMove event is not fired.
You can capture the pointer position at this time by hooking into the button's MouseMove. BUT, the pointer's position will be relative to the button, not the panel, so you need to add these coordinates to the button's location coordinate:
Point mousePoint;
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
mousePoint = e.Location;
}
private void button1_MouseMove(object sender, MouseEventArgs e)
{
mousePoint = new Point(button1.Location.X + e.Location.X, button1.Location.Y + e.Location.Y);
}