会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
the longing for love, the search for knowledge
光着脚
导航
博客园
首页
新随笔
联系
订阅
管理
公告
C# 使用WM_NCLBUTTONDOWN消息实现任意位置移动窗体
Posted on
2009-09-24 14:07
Heclei
阅读(
705
) 评论(
0
)
收藏
举报
Code
1
public
const
int
WM_NCLBUTTONDOWN
=
0xA1
;
2
public
const
int
HT_CAPTION
=
0x2
;
3
4
[DllImportAttribute(
"
user32.dll
"
)]
5
public
static
extern
int
SendMessage(IntPtr hWnd,
6
int
Msg,
int
wParam,
int
lParam);
7
[DllImportAttribute(
"
user32.dll
"
)]
8
public
static
extern
bool
ReleaseCapture();
9
10
private
void
Form1_MouseDown(
object
sender, MouseEventArgs e)
11
{
12
if
(e.Button
==
MouseButtons.Left)
13
{
14
if
((e.Clicks
==
1
))
15
{
16
ReleaseCapture();
17
18
SendMessage(
this
.Handle, WM_NCLBUTTONDOWN, HT_CAPTION,
0
);
19
}
20
}
21
}
刷新页面
返回顶部
博客园
© 2004-2025
浙公网安备 33010602011771号
浙ICP备2021040463号-3