进行无边界的形式移动? [英] Make a borderless form movable?

查看:155
本文介绍了进行无边界的形式移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,使一个没有边界(FormBorderStyle设置为无)移动鼠标点击下表上,就好像有一个边界,当一个形式?谢谢你。

Is there a way to make a form that has no border (FormBorderStyle is set to "none") movable when the mouse is clicked down on the form just as if there was a border? Thanks.

推荐答案

文章在$ C $的CProject细节的技术。基本上可以归结为:

This article on CodeProject details a technique. Is basically boils down to:

public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;

[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();

private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{     
    if (e.Button == MouseButtons.Left)
    {
        ReleaseCapture();
        SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
    }
}

这本质上是做的究竟的一样抓住一个窗口的标题栏,从窗口管理器的角度来看。

This essentially does exactly the same as grabbing the title bar of a window, from the window manager's point of view.

这篇关于进行无边界的形式移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆