Eye Dropper control in WPF

Introduction (View this article in Code Project)Usually we come across different types of eye dropper controls in designers. We can move the mouse over the desktop and other applications to pick the color under the mouse. A normal eye dropper will pick color only within the application like the one in Adobe Illustrator or Photoshop. But the... Continue Reading →

Change Windows cursor globally in WPF

It is very obvious that we can change the cursor in WPF using FrameworkElement.Cursor. But the trick is, it only works within your application and not outside your application Main Window. In case if you want to change the cursor for the entire OS, we don't have any direct way in WPF. But most of the developers... Continue Reading →

Capture Screenshot in WPF

Capturing screen shot in Windows Forms is straight forward. But in WPF, we need some Pinvoke calls. We going to use the methods from User32.dll and gdi32.dll. For more reference about available methods in User32.dll, go through here. public class InteropHelper    {        [DllImport("user32.dll")]        public static extern IntPtr GetDesktopWindow();         // http://msdn.microsoft.com/en-us/library/dd144871(VS.85).aspx        [DllImport("user32.dll")]        public static extern IntPtr GetDC(IntPtr hwnd);         // http://msdn.microsoft.com/en-us/library/dd183370(VS.85).aspx        [DllImport("gdi32.dll")]        [return: MarshalAs(UnmanagedType.Bool)]        public static extern bool BitBlt(IntPtr hDestDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, Int32 dwRop);         // http://msdn.microsoft.com/en-us/library/dd183488(VS.85).aspx        [DllImport("gdi32.dll")]        public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);         // http://msdn.microsoft.com/en-us/library/dd183489(VS.85).aspx        [DllImport("gdi32.dll", SetLastError = true)]        public static extern IntPtr CreateCompatibleDC(IntPtr hdc);         // http://msdn.microsoft.com/en-us/library/dd162957(VS.85).aspx        [DllImport("gdi32.dll", ExactSpelling = true, PreserveSig = true, SetLastError = true)]        public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);         // http://msdn.microsoft.com/en-us/library/dd183539(VS.85).aspx        [DllImport("gdi32.dll")]        public static extern bool DeleteObject(IntPtr hObject);         // http://msdn.microsoft.com/en-us/library/dd162920(VS.85).aspx        [DllImport("user32.dll")]        public static extern int ReleaseDC(IntPtr hwnd, IntPtr dc);}To get a copy of desktop screen, first we need to get the... Continue Reading →

Physics Game in Silverlight 4.0

Most of the times I wonder how to create a real physics movement and collision in Silverlight/WPF. A lot of Physics library has been developed to solve this problem. Farseer Physics is one of the best that I have ever seen.The Library is very easy to use and lot of samples and videos has been posted in... Continue Reading →

Up ↑