电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

如何拖动没有边框的窗体?


发布日期:2023/9/20
 

这个功能在VB需要借助于API函数才能实现而在中凭自己的功能就能实现首先设置窗体的FormBorderStyle属性为none以去掉窗体的边框然后在窗体上添加一个按钮窗体中的代码如下

Public Class Form

Inherits System<a _blank>Windows</a>FormsForm

Private mouse_offset As Point

Private Sub form_MouseDown(ByVal sender As Object _

ByVal e As SystemWindowsFormsMouseEventArgs) Handles MyBaseMouseDown

mouse_offset = New Point(eX eY)

End Sub

Private Sub form_MouseMove(ByVal Sender As SystemObject _

ByVal e As SystemWindowsFormsMouseEventArgs) Handles MyBaseMouseMove

按住鼠标左右键均可拖动窗体

If eButton = MouseButtonsLeft Or eButton = MouseButtonsRight Then

Dim mousePos As Point = Senderfindform()MousePosition

获得鼠标偏移量

mousePosOffset(mouse_offsetX mouse_offsetY)

设置窗体随鼠标一起移动

Senderfindform()Location = mousePos

End If

End Sub

Private Sub BtnExit_Click(ByVal sender As SystemObject _

ByVal e As SystemEventArgs) Handles ButtonClick

关闭窗体

MeClose()

End Sub

End Class

上一篇:使用silverlight中的Storyboard实现动画效果

下一篇:如何在生产环境使用Nuget