大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
设置窗体的text为空,设置窗体的controlbox属性为false,设置窗体的FormBorderStyle 属性为Sizable,就可以改变窗体大小了,并且可以在任务栏点击。
创新互联专注于企业成都全网营销、网站重做改版、单县网站定制设计、自适应品牌网站建设、HTML5、商城网站定制开发、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为单县等各大城市提供网站开发制作服务。
当用户按下左键时,为按下对象的MouseMove事件绑定处理方法,并记录鼠标坐标(窗体左上角为原点,在事件的MouseEventArgs类型的e参数中提供)。此时用户移动鼠标,保持窗体原点与鼠标新坐标的相对位置不变。当用户释放左键时,撤销按下对象的MouseMove事件处理方法
1、无边框窗体也就是无标题栏窗体,对于这样的窗体移动需要编程实现。
2、vb有两种办法实现,一直接编程实现,二调用windows API编程实现。
3、这里示例直接编程实现:
Option Explicit
Dim BolIsMove As Boolean, MousX As Long, MousY As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then BolIsMove = True
MousX = X
MousY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim CurrX As Long, CurrY As Long
If BolIsMove Then
CurrX = Me.Left - MousX + X
CurrY = Me.Top - MousY + Y
Me.Move CurrX, CurrY
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
BolIsMove = False
End Sub
设置全局变量:
Dim drag As Boolean
Dim mousex As Integer
Dim mousey As Integer
假设你想拖动的是Panel1控件,以及此控件上的 Label1(用于显示标题)和PictureBox4(用于显示图标):
Private Sub TitleMove_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown, Label1.MouseDown, PictureBox4.MouseDown
drag = True
mousex = Windows.Forms.Cursor.Position.X - Me.Left
mousey = Windows.Forms.Cursor.Position.Y - Me.Top
End Sub
Private Sub TitleMove_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove, Label1.MouseMove, PictureBox4.MouseMove
If drag Then
Me.Top = Windows.Forms.Cursor.Position.Y - mousey
Me.Left = Windows.Forms.Cursor.Position.X - mousex
End If
End Sub
Private Sub TitleMove_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp, Label1.MouseUp, PictureBox4.MouseUp
drag = False
End Sub