How come when I call the SetPixel function to set a pixel in iTunes, it does shows me the pixel in that specific application (like it should), whilst when calling the same function for Windows Media Player it doesn’t show at all. Also, this function doesn’t seem to work for fullscreen windows either. Why this great diversity? Any explanation would be greatly appreciated. Thanks in advance.
Share
As mentioned, it’s very easy not to get the result you are expecting because it’s not your window, and you ultimately have no control over what it does!
Two things you could do (one obviously being better than the other) are:
Use
GetDC (NULL)to get a handle to the screen device context. UseClientToScreento calculate the position of your pixel on the screen. CallSetPixelwith that handle. This will get cleared fairly quickly, though.Create your own top-level, popup, transparent (to messages), layered window with an appropriate colour key. Use
ClientToScreento calculate the position of the screen, and possiblyScreenToClientto make sure it goes properly onto your window (which should theoretically have the same client dimensions as the screen). Draw the pixel onto your window and you will be in control of when it leaves.If using the second, your extended window style should be:
and your normal window style should be:
The dimensions can be found using
GetSystemMetricswith the valuesSM_CXSCREENandSM_CYSCREEN.To set the colour key, use
SetLayeredWindowAttributes:Where
red,green, andbluemake up the background colour of your window, and should never appear as an actual colour. That way your background will not be drawn, giving an unnoticeable difference to the user, but when anything is drawn, it will show up.