vb.net如何拖动窗体,vb程序设计窗体移动

VB.net怎么实现运行时鼠标拖动改变控件的大小啊

控件是可以显示在里面的,你只要加个label,把label的属性设为visualble=fause就行。设置鼠标经过头像的mouseHover和mouseLeave事件,当mouseHover时label的属性visualble=true,当mouseLeave时label的属性visualble=fause即可。窗体的鼠标事件可以设置控件的cursor属性,里面可以选择许多种鼠标图形。 只要是正常的Form都可以改变窗体大小,但是无边框的窗体只能用函数改变或者设置属性,在debug后是不能改变的。拖动窗体需要在窗体的load时间里面写入当鼠标单击不放时的事件即可,不难。

在平安等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站建设、成都网站设计 网站设计制作按需求定制制作,公司网站建设,企业网站建设,品牌网站建设,成都全网营销,成都外贸网站建设,平安网站建设费用合理。

vb.net窗体的移动问题

Public X, Y As Integer

Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown

X = e.X : Y = e.Y

End Sub

Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove

If X = e.X And Y = e.Y Then Exit Sub

If e.Button = Windows.Forms.MouseButtons.Left Then

Me.Left = Me.Left + e.X - X

Me.Top = Me.Top + e.Y - Y

End If

End Sub

VB.NET如何实现无边框窗体拖动? 如果能指定控件拖动更好 希望能有一点分析 使用VS2015

VB6.0写的,代码很简单,无意中写成的。应该可以参考。不需要任何api函数。在无边框窗体顶部中放入一个label标签。然后用label的 mouse down 和mouse move事件实现

Dim a, b As Single

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

a = X

b = Y

End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 1 Then

Form1.Move Left + X - a, Top + Y - b

End If

End Sub

VB.NET怎么能拖动无框窗体?请注意看补充,高手进!

设置全局变量:

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

VB.net怎样按住鼠标移动无边框窗体

1.在mouse事件中实现

2.调用windows API

实现方式为:

1.在mouse事件中实现

[csharp] view plain copy

Point mouseOff;//鼠标移动位置变量

bool leftFlag;//标签是否为左键

private void groupControl1_MouseUp(object sender, MouseEventArgs e)

{

if (leftFlag)

{

leftFlag = false;//释放鼠标后标注为false;

}

}

private void groupControl1_MouseMove(object sender, MouseEventArgs e)

{

if (leftFlag)

{

Point mouseSet = Control.MousePosition;

mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置

Location = mouseSet;

}

}

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

mouseOff = new Point(-e.X, -e.Y); //得到变量的值

leftFlag = true; //点击左键按下时标注为true;

}

}

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

mouseOff = new Point(-e.X, -e.Y); //得到变量的值

leftFlag = true; //点击左键按下时标注为true;

}

}

2.调用windows API

调用前需要添加using System.Runtime.InteropServices;

[csharp] view plain copy

[DllImport("user32.dll")]

public static extern bool ReleaseCapture();

[DllImport("user32.dll")]

public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

ReleaseCapture(); //释放鼠标捕捉

//发送左键点击的消息至该窗体(标题栏)

SendMessage(Handle, 0xA1, 0x02, 0);

}

}

如何移动VB中的无边框窗体

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


本文名称:vb.net如何拖动窗体,vb程序设计窗体移动
文章分享:http://pwwzsj.com/article/hdcggs.html