Sunday, June 10, 2007

Obtaining mouse x and y coordinates from a Windows message, in C#

The lower 4 bits of LParam represent the mouse x coordinate; the upper 4 bits represent the y coordinate.
protected override void WndProc(ref Message m)
{
int x = (m.LParam.ToInt32() << 16) >>16;
int y = m.LParam.ToInt32() >> 16;

base.WndProc(ref m);
}
reference: http://www.codeproject.com/cs/miscctrl/DateTimeSlicker.asp?df=100&forumid=28242&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;exp=0&select=902128