求助:Form拖动问题?
我现在有个from窗体,设置了最大和最小尺寸,现在运行时,是显示在中间,最大化后,跑到了左上角,我现在想拖动这个窗体,保持最大化的状态不变,怎么实现呢,谢谢大牛们
程序代码:
using System.Drawing; using System.Windows.Forms; namespace DragWindowWithMaxSize { public sealed partial class FormMain : Form { #region 常量 private const int WM_NCLBUTTONDBLCLK = 0x00a3; private const int WM_SYSCOMMAND = 0x0112; private const int SC_MAXMIZE = 0xf030; #endregion public FormMain() { InitializeComponent(); } protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_NCLBUTTONDBLCLK: { if (WindowState == FormWindowState.Normal) { Location = new Point(0,0); Size = MaximumSize; } } break; case WM_SYSCOMMAND: { switch((uint)m.WParam) { case SC_MAXMIZE: Size = MaximumSize; WindowState = FormWindowState.Maximized; return; } } break; } base.WndProc(ref m); } } }
[ 本帖最后由 mmxo 于 2012-11-22 18:52 编辑 ]