非标题区域拖动窗体VB

Posted chenxiehan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了非标题区域拖动窗体VB相关的知识,希望对你有一定的参考价值。

窗体空白区域按下鼠标左键即可任意拖动窗体,不需要拖动标题栏。

Dim MoveScreen As Boolean
Dim MousX As Integer
Dim MousY As Integer
Dim CurrX As Integer
Dim CurrY As Integer

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        MoveScreen = True
        MousX = X
        MousY = Y
    End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If MoveScreen Then
        CurrX = Form1.Left - MousX + X
        CurrY = Form1.Top - MousY + Y
        Form1.Move CurrX, CurrY
    End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MoveScreen = False
End Sub

 

以上是关于非标题区域拖动窗体VB的主要内容,如果未能解决你的问题,请参考以下文章

vb.net: 一个用户控件,把它放在窗体中,当拖动它时,窗体也随之移动,这样这个窗体就不需要标题栏来拖动了

JavaFX窗口拖动

c# WINFORM窗体如何设置才可以不能随意拖动大小

vb.net 窗体布局的问题

vb中如何改变对话框的字体

C#移动无边框的窗体怎么写。