How to check if the WPF Window is being dragged [duplicate] - c#

This question already has answers here:
Determining when a WPF window is being moved
(3 answers)
Closed 7 years ago.
In need to get whether or not my WPF application's Window is currently in the process of being dragged or re-sized. I need to prevent a specific action from happening if this is the case.
I need to check if the window is currently in any situation where the mouse is being held down on the the part of the window that can preposition it.
I am assuming there is probably some information somewhere on the
Application.Current.MainWindow
property. Or maybe there is a few events that I need to keep track of to have this information.
Any ideas how I would do this? Thanks in advance.

Subscribe to the LocationChanged event.

Set the ResizeBegin and ResizeEnd event. They should both fire when the application is being moved, and disable your feature when Begin is called and until End finishes.
EDIT: Just realized this is WPF, in which case check this article: Determining when a WPF window is being moved

Related

How can I get the coordinates of a click on the screen [duplicate]

This question already has answers here:
Getting Position of mouse cursor when clicked out side the form's boundary
(5 answers)
Closed 8 years ago.
i'm trying to automate some actions with a c# bot. The program should work in this way:
a. the user add actions to a list of actions that the bot will use after the setup.
b. for example the user add the "auto-click" action.
c. then the program hide his window to let the user click and get the coordinates.
Now, I know how to hide the program window but I don't know how to manage how to get the coordinates of the screen when the user clicks. do anybody know how to achieve this?
Edit: my question is a bit different from the one posted below, i'm not trying to detect mouse clicks in the main form...
you might be looking for this
How to get mouse pointer position using javascript for internet explorer?
One of the answer conrtains cross browser solution not just IE.

Make my application vague while Show "Spinning Wheel” [duplicate]

This question already has answers here:
How can I make the cursor turn to the wait cursor?
(11 answers)
Closed 9 years ago.
I have Windows Forms application and while some operation is in progress i want to show Spinning Wheel:
http://preloaders.net/en/search/circle
So i created pictureBox and while my operation is in progress i want to see that Wheel but i want it to seen like in web pages, i want it over my controllers at the middle of the application and if it possible i want the rest of my application become vague.
is it possible ?
Simple solution:
pictureBox1.BringToFront();
pictureBox1.Dock = DockStyle.Fill;
Another option is transparent background and FormBorderStyle set to None. Show this form with ShowDialog() to avoid interaction with main form while it is shown.
NOTE: WinForms is not a Web application. Usually when you have some background process, then you set waiting cursor and disable controls. If you want to display progress, then can use ProgressBar.

How do I get the element that the cursor is over during a keypress? [duplicate]

This question already has answers here:
WPF Get Element(s) under mouse
(3 answers)
Closed 9 years ago.
I'm writing a WPF application, and I've come to a point where I need to get the UI Element that the mouse cursor is over at the time of a keypress. Basically, we have lists on the screen, and if the user enters Ctrl+Shift+F, they will be able to filter the objects just in the list that their mouse is over. I've done some research on this, and the only related questions I've found have to do with moving the cursor to a certain element on a keypress, not finding the element that the cursor is already over. I don't have any code to show for this since it is more of a conceptual question, but if you need any more detail from me, please let me know. Thanks!
var elementundermouse = Mouse.DirectlyOver as FrameworkElement;

Windows Desktop Size changed event? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Detect change of resolution c# WinForms
I have an application written in C# where my window is docked to the edge of the screen.
I need to know where I can find the event if the resolution has changed so I can call the Dock method so I can repaint my window.
On the form object I can only see the SystemColorsChanged event.
You're looking for the SystemEvents.DisplaySettingsChanged event.

Prevent window from snapping to screen edges [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do you disable Aero Snap in an application?
Is there a way to prevent a WPF window from snapping to screen edges (i.e. Aero snap)?
I know this can be disabled by the user in the OS, but I want to prevent only my window from getting rearranged.
For example, modal windows do not get snapped like that. I imagine it can be set for a WPF window as well, but I do not know how.
There's no direct way of doing this except you set ResizeMode="NoResize" and implement the resize behavior manually or EXTREME SOLUTION could be (on an application basis) modifying a shortcut to your .exe, on the Compatibility tab, check "Disable desktop composition".

Categories