Question: How do I get the coordinates of a WM\_NCHITTEST message in C# code?  

I'd love to get the fastest way, because performance is a requirement.

Answer: 
From MSDN:

> 
> **wParam**  
> 
>  This parameter is not used. 
> 
> 
> **lParam**  
> 
>  The low-order word specifies
>  the x-coordinate of the cursor. The
>  coordinate is relative to the
>  upper-left corner of the screen.  
> 
>  The high-order word specifies the
>  y-coordinate of the cursor. The
>  coordinate is relative to the
>  upper-left corner of the screen.
> 
> 
> 

So you just need to extract the low-order and high-order words from the message's `lParam`:

```
int x = lParam.ToInt32() & 0x0000FFFF;
int y = (int)((lParam.ToInt32() & 0xFFFF0000) >> 16)
Point pos = new Point(x, y);

```

I wouldn't worry too much about performance, since these operations are just bit level arithmetic...

Note that these coordinates are relative to the screen. If you want coordinates relative to a control (or form), you can use the `PointToClient` method:

```
Point relativePos = theControl.PointToClient(pos);

```
I know this question was already answered and all but...

```
Point p = new Point(m.LParam.ToInt32());

```

System.Drawing.Point now has a constructor specifically designed to accept this exact value. Strictly speaking, I think this is probably the **easiest** way.

To be perfectly honest, I have no idea if this constructor even existed when the other answers were posted.

That all being said, this probably isn't any **faster** because takrl's answer is almost certainly what the aforementioned constructor does internally anyway.