问你一下:关于C# 窗体 无边框移动的问题!我已经看了你的答案,可为什么我的不行啊!!
展开全部
using System.Runtime.InteropServices;
using System;
public static class WIN32
{
[DllImport("user32.dll")]
static extern bool ReleaseCapture();
[DllImport("user32.dll")]
static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
const int WM_SYSCOMMAND = 0x0112;
const int SC_MOVE = 0xF010;
const int HTCAPTION = 0x0002;
public static void MoveUI(IntPtr UIHandle)
{
try
{
ReleaseCapture();
SendMessage(UIHandle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
catch{}
}
}
加入这个类,然后在 Form 或者控件的调用即可,比如:
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
WIN32.MoveUI(this.Handle);
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
WIN32.MoveUI(this.Handle);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询