Screen.FromControl
, Screen.FromPoint
and Screen.FromRectangle
should help you with this. For example in WinForms it would be:
class MyForm : Form { public Rectangle GetScreen() { return Screen.FromControl(this).Bounds; } }
I don’t know of an equivalent call for WPF. Therefore, you need to do something like this extension method.
static class ExtensionsForWPF { public static System.Windows.Forms.Screen GetScreen(this Window window) { return System.Windows.Forms.Screen.FromHandle(new WindowInteropHelper(window).Handle); } }
Related Posts:
- WFP Grid: MouseRightButtonDown firing occuring BEFORE SelectionChanged on grid. Causing syncing issue
- XAML Binding Groups
- Metadata file ‘.dll’ could not be found
- How to resolve this System.IO.FileNotFoundException
- How to resolve this System.IO.FileNotFoundException
- MSHTML DLL on Windows 10
- MSHTML DLL on Windows 10
- The calling thread cannot access this object because a different thread owns it
- How to add comments into a Xaml file in WPF?
- The calling thread must be STA, because many UI components require this in WPF
- How to use WPF Background Worker
- Page vs Window in WPF?
- How do I exit a WPF application programmatically?
- How to avoid a System.Runtime.InteropServices.COMException?
- Using FolderBrowserDialog in WPF application
- What is IP address ‘::1’?
- How to fix No connection could be made because the target machine actively refused it 127.0.0.1:64527
- What is the yield keyword used for in C#?
- Join/Where with LINQ and Lambda
- C# compiler error: “not all code paths return a value”
- C# equivalent of C++ map
- The page was not displayed because the request entity is too large on IIS
- Export Pervasive to MySQL (C#)
- Why use the params keyword?
- What does plus equals(+=) operator means here?
- Unity cannot convert from ‘string’ to ‘int’
- The request was aborted: Could not create SSL/TLS secure channel
- The request was aborted: Could not create SSL/TLS secure channel
- finding the maximum length of lists in c#
- The located assembly’s manifest definition does not match the assembly reference
- OnTriggerEnter not working at Unity3D
- The requested resource does not support HTTP method ‘GET’
- Rename a file in C#
- What does mscorlib stand for?
- What is the best way to iterate over a dictionary?
- Does not contain a static ‘main’ method suitable for an entry point
- Checking if an object is null in C#
- How to use Global Variables in C#?
- Unity3d no Monobehaviour scripts in the file, or their names don’t match the file name
- Add new item in existing array in c#.net
- What is and how to fix System.TypeInitializationException error?
- Adding values to a C# array
- How to initialize a list of strings (List
) with many string values - What does {0} mean when found in a string in C#?
- Collection was modified; enumeration operation may not execute
- Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on
- Unity – Gameobject look at mouse
- How to use html.ValidationMessageFor
- EF 5 Enable-Migrations : No context type was found in the assembly
- Visual studio 2019 freezes when debugging
- How to make an HTTP POST web request
- Are 2 dimensional Lists possible in c#?
- Passing just a type as a parameter in C#
- How to stop C# console applications from closing automatically? [duplicate]
- What represents a double in sql server?
- Can I send SMS Messages from a C# Application?
- How do you sort a dictionary by value?
- EntityType has no key defined error
- regular expression “.*[^a-zA-Z0-9_].*”
- Sharing violation IOException while reading and writing to file C#
- How to delete object?
- Carriage return and Line feed… Are both required in C#?
- Inconsistent Accessibility: Parameter type is less accessible than method
- How to get correct timestamp in C#
- Cannot implicitly convert type ‘int’ to ‘string’ C# class
- How do I exit a foreach loop in C#?
- If a folder does not exist, create it
- C# “No suitable method found to override.” — but there is one
- System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
- What is the purpose of global.asax in asp.net
- How to add a string to a string[] array? There’s no .Add function
- How to block until an event is fired in c#
- Case insensitive ‘Contains(string)’
- How to catch all exceptions in c# using try and catch?
- Getting “Handshake failed…unexpected packet format” when using WebClient.UploadFile() with “https” when the server has a valid SSL certificate
- Receiving access denied error from Visual Studio when trying to change target framework
- When do we use ANTLR
- How would you count occurrences of a string (actually a char) within a string?
- Socket.Select returns error “An operation was attempted on something that is not a socket”
- Get dictionary key by value
- Convert from List into IEnumerable format
- How do I exit from a function?
- Rotate object in Unity 3D
- Using OpenGl with C#? [closed]
- C# equivalent to Java’s charAt()?
- How to play a sound in C#, .NET
- Convert SQL to LINQ Query
- How to resolve file being used by another process?
- How to crop an image using C#?
- How do you wait for input on the same Console.WriteLine() line?
- Why doesn’t C# have header files? Will the namespace take care of everything?
- Define: What is a HashSet?
- Convert string to decimal, keeping fractions
- “A namespace cannot directly contain members such as fields or methods”
- Format of the initialization string does not conform to specification starting at index 0
- How can I generate random alphanumeric strings?
- Download file of any type in Asp.Net MVC using FileResult?
- How do you do a deep copy of an object in .NET?
- Cannot declare instance members in a static class in C#
- How to convert HTML to PDF using iTextSharp