C# 控件拖动
2021-05-05 09:27
标签:first 标准 ring message idt highlight alt 加载 plain https://zhidao.baidu.com/question/2116834779399609987.html 把上面语句加载窗体类文件中,然后在拖拽的控件上加事件,比如我是一个panel 这种才是windows标准的拖拽事件,下面那位,拖动的时候窗体会闪烁不停,一直在渲染背景 C# 控件拖动 标签:first 标准 ring message idt highlight alt 加载 plain 原文地址:http://www.cnblogs.com/LuoEast/p/7687869.html[DllImport(
"user32.dll"
, EntryPoint =
"ReleaseCapture"
)]
public
static
extern
void
ReleaseCapture();
[DllImport(
"user32.dll"
, EntryPoint =
"SendMessage"
)]
public
static
extern
void
SendMessage(
int
hwnd,
int
wMsg,
int
wParam,
int
lParam);
private
void
panelForm_MouseDown(
object
sender, MouseEventArgs e)
{
if
(e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage((
int
)移动的对象.Handle, 0xA1, 2, 0);
//是窗体自身就是
//SendMessage((int)this.Handle, 0xA1, 2, 0);
//panel就是SendMessage((int)panel1.Handle, 0xA1, 2, 0);
}
}