【发布时间】:2020-08-21 09:55:25
【问题描述】:
不确定我是否在标题中解释得很好;
如果您在 Windows 上,单击并拖动 FireFox/Chrome/其他应用程序的标题栏并将其拖动到屏幕的顶部或侧面。它会产生一种奇怪的效果,当你释放捕获时,根据你拖动它的位置,它会最大化或分割屏幕。
当我使用App.FormBorderStyle = FormBorderStyle.None; 时,当我将它拖到顶部时,它不会给我拆分/最大效果。我已启用拖动:
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool ReleaseCapture();
// this is the panel i use as a title bar for dragging
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
现在,我怎样才能启用拖动到屏幕顶部并让窗口显示最大/拆分效果的功能。
谢谢。
【问题讨论】:
-
你仍然应该在 lParam 中传入 X / Y 位置。不知道这是否会解决它。
标签: c# visual-studio winforms