本文实例讲述了c#实现winform无边框移动的方法。分享给大家供大家参考。具体如下:
const int htleft = 10; const int htright = 11; const int httop = 12; const int httopleft = 13; const int httopright = 14; const int htbottom = 15; const int htbottomleft = 0x10; const int htbottomright = 17; protected override void wndproc(ref message m) { switch (m.msg) { case 0x0084: base.wndproc(ref m); point vpoint = new point((int)m.lparam & 0xffff, (int)m.lparam >> 16 & 0xffff); vpoint = pointtoclient(vpoint); if (vpoint.x <= 5) if (vpoint.y <= 5) m.result = (intptr)httopleft; else if (vpoint.y >= clientsize.height - 5) m.result = (intptr)htbottomleft; else m.result = (intptr)htleft; else if (vpoint.x >= clientsize.width - 5) if (vpoint.y <= 5) m.result = (intptr)httopright; else if (vpoint.y >= clientsize.height - 5) m.result = (intptr)htbottomright; else m.result = (intptr)htright; else if (vpoint.y <= 5) m.result = (intptr)httop; else if (vpoint.y >= clientsize.height - 5) m.result = (intptr)htbottom; break; case 0x0201://鼠标左键按下的消息 m.msg = 0x00a1;//更改消息为非客户区按下鼠标 m.lparam = intptr.zero;//默认值 m.wparam = new intptr(2);//鼠标放在标题栏内 base.wndproc(ref m); break; default: base.wndproc(ref m); break; } }
希望本文所述对大家的c#程序设计有所帮助。
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!
网友评论