Color of a screen pixel: Difference between revisions

added C
m (Omiting MUMPS)
(added C)
Line 12:
In a graphics mode (for instance, <tt>SCREEN 13</tt> or <tt>SCREEN 12</tt>)
<lang qbasic>color = point(x, y)</lang>
 
=={{header|C}}==
{{works with|Windows}}
<lang c>COLORREF getColorAtCursor(void) {
POINT p;
COLORREF color;
HDC hDC;
BOOL b;
 
// Get the device context for the screen
hDC = GetDC(NULL);
if (hDC == NULL)
return CLR_INVALID;
 
// Get the current cursor position
b = GetCursorPos(&p);
if (!b)
return CLR_INVALID;
 
// Retrieve the color at that position
color = GetPixel(hDC, p.x, p.y);
 
// Release the device context again
ReleaseDC(GetDesktopWindow(), hDC);
 
return color;
}</lang>
 
=={{header|C sharp|C#}}==
Anonymous user