> hdcScrn=CreateDC("DISPLAY",0,0,0);
There's your problem. You are creating thousands of new DC's without ever deleting them. You probably just need to create one each time you loop back.
Code:
hdcScrn=CreateDC("DISPLAY",0,0,0);
for (INT col = cntx; col < 260; col += 10)
{
for (INT row = cnty; row < 260; row += 10)
{
for (INT y = (row - 20); y < (row + 30); y += 10)
{
for (INT x = (col - 20); x < (col + 30); x += 10)
{
GetCursorPos(&pt);
clr=GetPixel(hdcScrn,pt.x,pt.y);
COLORREF pixColor = GetPixel(hdcScrn,x,y);
SetCursorPos(col,row);
// Some junk removed.
}
}
}
}
Or otherwise delete the DC within the inner loop.
Code:
GetCursorPos(&pt);
hdcScrn=CreateDC("DISPLAY",0,0,0);
clr=GetPixel(hdcScrn,pt.x,pt.y);
COLORREF pixColor = GetPixel(hdcScrn,x,y);
SetCursorPos(col,row);
// Some junk removed.
DeleteDC(hdcScrn);