日期:2014-05-17 浏览次数:21162 次
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, int lParam);
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0201)
{
int xPos = m.LParam.ToInt32() & 0xFFFF;
int yPos = (m.LParam.ToInt32()) >> 16;
Text = xPos.ToString() + " " + yPos.ToString();
}
base.WndProc(ref m);
}
private void button1_Click(object sender, EventArgs e)
{
Point p = new Point(101, 201);
int point = p.X + (p.Y << 16);
SendMessage(this.Handle, 0x0201, IntPtr.Zero, point);
}