当前位置: 移动技术网 > IT编程>开发语言>c# > C# 实现窗口无边框,可拖动效果

C# 实现窗口无边框,可拖动效果

2019年07月18日  | 移动技术网IT编程  | 我要评论

具体代码如下所示:

 #region 无边框拖动效果
    [dllimport("user32.dll")]//拖动无窗体的控件
    public static extern bool releasecapture();
    [dllimport("user32.dll")]
    public static extern bool sendmessage(intptr hwnd, int wmsg, int wparam, int lparam);
    public const int wm_syscommand = 0x0112;
    public const int sc_move = 0xf010;
    public const int htcaption = 0x0002;
    private void start_mousedown(object sender, mouseeventargs e)
    {
      //拖动窗体
      releasecapture();
      sendmessage(this.handle, wm_syscommand, sc_move + htcaption, 0);
    }
    #endregion

在窗口属性界面添加事件服务

总结

以上所述是小编给大家介绍的c# 实现窗口无边框,可拖动效果,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网