Your cursor may be out by one or 2 pixcels because if you use GetWindowRect() or GetClientRect() as these functions do not include the last row in the RECT (reducing the area by one each) Try adding one or two to your offset.