Hopefully this is the right forum for this. I have a glaring red pixel on my nice new monitor that just won't come out. I've tried all the physical and software techniques for getting it out and they have failed. What I would like to do is create a program (using c# Visual Studio Express sp1) that runs from the tray and will display a gray pixel in the location of my LCD's stuck pixel, which should be enough to mask it most of the time. The catch is that it needs to take priority over any other screen and be on top even during games and movies.
Can this be done with c#? I am very new to programming and a more experienced friend said c# may not be the best language to code this in. I've seen quick guides on how to draw a single pixel on screen, but the methods they use don't seem to exist in the lastest .Net 3.5/VS2008 package. I'm just looking for some pointers. Thanks
Loading
AlanPosted Aug 13, 2008, 7:37 PM
It's possible to draw a pixel anywhere on the desktop from C# by calling the API function, GetDC(), to get the desktop handle, obtain a Graphics object from that and then draw a 1 x 1 bitmap of the appropriate color. The code for this would be:
using
System.Drawing; using System.Runtime.InteropServices;// ...
[
DllImport("User32.dll")] public extern static IntPtr GetDC(IntPtr hWnd);// ...
IntPtr
desktopHandle = GetDC(IntPtr.Zero); Graphics g = Graphics.FromHdc(desktopHandle); Bitmap bmp = new Bitmap(1,1);bmp.SetPixel(0,0,
Color.Gray);g.DrawImageUnscaled(bmp, x, y); // where x, y are the desktop co-ordinates of the pixel
As you may already know, the NotifyIcon class can be used to create an icon for the application in the tray:
http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx
That should help you get started with this but you'll need to take further steps to ensure the dead pixel, when not covered by another application, is always colored gray as the bitmap will not be automatically redrawn when the desktop is refreshed.