我在 Windows Forms 中创建了一个表单,无论我点击哪里都可以拖动它。我通过重写 WndProc 函数来实现它,该函数反过来修改每次点击,因为它是标题栏点击:
//found at: http://stackoverflow.com/questions/3995009/how-to-make-a-window-draggablec-winforms
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
///
/// Handling the window messages
///
protected override void WndProc(ref Message message)
{
base.WndProc(ref message);
if (message.Msg == WM_NCHITTEST && (int)message.Result == HTCLIENT)
message.Result = (IntPtr)HTCAPTION;
}
问题是现在当我双击时,窗口变成全屏,这是不需要的。我怎样才能阻止这种行为?