Note that the cursor shape is always changed on every mouse move because the windows that is under the cursor is always receiving WM_SETCURSOR message, so you are fighting against the windows that are under your cursor. On way to avoid that is capturing the mouse by your HWND. A good thing about mouse capturing is that while you capture the mouse, no WM_SETCURSOR messages are sent to windows under the cursor, so you can set your on cursor and it will stay until you release the capture. Here you can find a small example prog about using mouse capture. http://www.codeproject.com/Tips/127813/Using-SetCapture-and-ReleaseCapture-correctly.aspx[^]. Some hints about picking a color: The easiest way is to ask the user to move the cursor above a pixel and to ask him to press for example a key because you can not prevent the window below the cursor from receiving the click. Another more sophisticated solution can be creating a big window that covers the whole virtual screen (not THE SCREEN but the virtual screen including all monitors!) and you could capture and draw the actual image of the whole virtual screen on this big window. In this case you don't even need the SetCapture() trick, and its easy to receive the mouse click. Another quick note: If you use a window that covers the whole screen than either return 1 from the window's WM_ERASEBKGND message handler, or do the whole painting in WM_ERASEBKGND instead of WM_PAINT to avoid flickering when you show up the window! EDIT: Or maybe you could use a color picking mechanism that is similar to the HWND picker of spy++. The user presses down the left button on your color picker control that captures the mouse and sets the cursor. After it the user moves the cursor above a pixel and releases the left mouse button, this is when you take action. During mousemove you can update your info area to show something about the actual pixel.
modified on Thursday, December 2, 2010 11:16 AM