//重写基类的一个方法。
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x46:
Rectangle rect = Screen.GetWorkingArea(this);
WINDOWPOS winPos = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS));
if (winPos.x + winPos.cx > rect.Right)
{
winPos.x = rect.Right - winPos.cx;
}
if (winPos.y + winPos.cy > rect.Bottom)
{
winPos.y = rect.Bottom - winPos.cy;
}
if (winPos.x < rect.Top)
{
winPos.x = rect.Top;
}
if (winPos.y < rect.Left)