拖动鼠标无国界的windows窗体 [英] Drag borderless windows form by mouse
本文介绍了拖动鼠标无国界的windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
C# - 进行无边界形式活动
我已经做了无形式在C#中的边界,通过设置
I have made a form without border in C#, by setting
this.FormBorderStyle = FormBorderStyle.None;
现在,问题是,我如何通过拖动鼠标呢?
Now, problem is how can I drag it by mouse?
推荐答案
这应该是你在找什么<一个href=\"http://jachman.word$p$pss.com/2006/06/08/enhanced-drag-and-move-winforms-without-having-a-titlebar/\">\"Enhanced:拖动和移动的WinForms
public partial class MyDraggableForm : Form
{
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
///
/// Handling the window messages
///
protected override void WndProc(ref Message message)
{
base.WndProc(ref message);
if (message.Msg == WM_NCHITTEST && (int)message.Result == HTCLIENT)
message.Result = (IntPtr)HTCAPTION;
}
public MyDraggableForm()
{
InitializeComponent();
}
}
随着博客文章状态,这是一种方法,傻瓜制度。这样,您就不需要去想鼠标向上/向下事件。
As the blog post states, this is a way to "fool" the system. This way you don't need to think about mouse up/down events.
这篇关于拖动鼠标无国界的windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文