April 14th, 1999, 02:28 AM
Anyone have some code to tell what is the pixel color under the cursor?
|
Click to See Complete Forum and Search --> : pixel under cursor? April 14th, 1999, 02:28 AM Anyone have some code to tell what is the pixel color under the cursor? Saurabh Dasgupta April 14th, 1999, 04:27 AM Hi, You can do the following to know what is the pixel color under the mouse cursor. 1.Get the cursor location using API GetCursorPos. Remember this is in screen coordinates. You need to convert it to client window coordinates using API ScreenToClient 2.Get a handle to the device context for this window which has the cursor contained in it. (you can use WindowFromPoint ChildWindowFromPoint for this) 3.Get a handle to a device context, and then use the API GetPixel I think this should solve the problem. Regards Saurabh Tim G April 14th, 1999, 04:38 AM POINT pt; GetCursorPos( &pt ); HDC sdc = GetDC( 0 ); COLORREF color = GetPixel( sdc, pt.x, pt.y ); ReleaseDC( 0, sdc ); codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |