User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 370,605 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,034 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 2358 | Replies: 1
Reply
Join Date: Feb 2006
Location: Illinois
Posts: 14
Reputation: andrax is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
andrax andrax is offline Offline
Newbie Poster

Help win32 api mouse coordinates weird

  #1  
Feb 10th, 2006
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;
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,480
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Rep Power: 8
Solved Threads: 98
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: win32 api mouse coordinates weird

  #2  
Feb 10th, 2006
		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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 6:33 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC