System.Drawing.Point vs. System.Windows.Point
If you're using PInvoke to call Win32 API functions and start seeing strange return values, make sure you're using the correct Point type. For example, the following code:
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern int GetCursorPos(ref Point lpPoint);
... takes a System.Drawing.Point, not a System.Windows.Point. This may well bite you when you're coding against WPF and have references to WindowsBase.dll but not System.Drawing.dll. The code will compile and run but you'll see very strange values being returned as a result of the two structures not being equivalent.
This is easily enough fixed by qualifying the type:
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern int GetCursorPos(ref System.Drawing.Point lpPoint);



Recent comments
1 week 1 day ago
3 weeks 3 days ago
3 weeks 6 days ago
11 weeks 1 day ago
15 weeks 5 days ago
31 weeks 15 hours ago
31 weeks 20 hours ago
37 weeks 3 days ago
37 weeks 3 days ago
37 weeks 4 days ago