I'm writting a program where I need the coordinates of the mouse when it's clicked inside the client area. For some reason, the coordinates seem to be in base 21, maybe higher (I've seen the character k). I'm not sure why this is happening.

Here's the mouse section of the message loop

case WM_LBUTTONDOWN:
{
	int x = ((int)(short)LOWORD(lParam));
	int y = ((int)(short)HIWORD(lParam));

	char buf[20];
	string s = itoa(x, buf, 21);
	s += ", ";
	s += itoa(y, buf, 21);
	MessageBox(hwnd, s.c_str(), "Distance", MB_OK | MB_APPLMODAL);

	return 0;
}
std::string s(itoa(x, buf, 10));
		s += ", ";
		s += itoa(y, buf, 10);;

Read the specification for atoi .

What is the meaning of this cast?

int x = ((int)(short)LOWORD(lParam));

Just using

WORD x = LOWORD( lParam ) ;

will work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.