如何使一个窗口可拖动(C#的WinForms)? [英] How to make a window Draggable(C# Winforms)?

查看:124
本文介绍了如何使一个窗口可拖动(C#的WinForms)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有形式。我已经启用表单上的透明度,我已删除了它的标题栏和边框。里面,我已经创建了一个自定义用户界面,其中有这样一个窗口相同的功能。基本上,我的想法是创建自定义窗口。

I have form. I have enabled the transparency on the form and I have removed it's Title Bar and Border. Inside that i have created a Custom UI, Which have the same features like a window. Basically, my idea is to create custom window.

一切工作正常,但只有Windows拖着不工作。我不知道如何启用它。我用Google搜索了这一点。但我没有找到我任何有用的信息。

Everything is working as expected but only the windows dragging is not working. I am not sure how to enable it. I googled for this. But i didn't find any useful info for me.

请帮我实现这个窗口拖动。

Please help me to implement this window dragging.

推荐答案

我实现了通过捕捉鼠标按下(uncapture上的mouseup)这种行为,然后鼠标移动。

I've implemented this behavior by capturing mousedown (uncapture on mouseup), and then mousemove.

刚刚移动窗体坐标(左,上),等量鼠标移动(这些事件让鼠标移动量)。

Just move the form co-ordinates (left, top), equivalent amounts to the mouse movement (those events have the amount the mouse moved).

这工作对我罚款。

这篇关于如何使一个窗口可拖动(C#的WinForms)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆