真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net拖動(dòng)窗口,vbnet web窗體

如何移動(dòng)VB中的無(wú)邊框窗體

1、無(wú)邊框窗體也就是無(wú)標(biāo)題欄窗體,對(duì)于這樣的窗體移動(dòng)需要編程實(shí)現(xiàn)。

專注于為中小企業(yè)提供成都網(wǎng)站建設(shè)、網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)改則免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了近1000家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

2、vb有兩種辦法實(shí)現(xiàn),一直接編程實(shí)現(xiàn),二調(diào)用windows API編程實(shí)現(xiàn)。

3、這里示例直接編程實(shí)現(xiàn):

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如何實(shí)現(xiàn)無(wú)邊框窗體拖動(dòng)? 如果能指定控件拖動(dòng)更好 希望能有一點(diǎn)分析 使用VS2015

VB6.0寫(xiě)的,代碼很簡(jiǎn)單,無(wú)意中寫(xiě)成的。應(yīng)該可以參考。不需要任何api函數(shù)。在無(wú)邊框窗體頂部中放入一個(gè)label標(biāo)簽。然后用label的 mouse down 和mouse move事件實(shí)現(xiàn)

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怎樣按住鼠標(biāo)移動(dòng)無(wú)邊框窗體

1.在mouse事件中實(shí)現(xiàn)

2.調(diào)用windows API

實(shí)現(xiàn)方式為:

1.在mouse事件中實(shí)現(xiàn)

[csharp] view plain copy

Point mouseOff;//鼠標(biāo)移動(dòng)位置變量

bool leftFlag;//標(biāo)簽是否為左鍵

private void groupControl1_MouseUp(object sender, MouseEventArgs e)

{

if (leftFlag)

{

leftFlag = false;//釋放鼠標(biāo)后標(biāo)注為false;

}

}

private void groupControl1_MouseMove(object sender, MouseEventArgs e)

{

if (leftFlag)

{

Point mouseSet = Control.MousePosition;

mouseSet.Offset(mouseOff.X, mouseOff.Y); //設(shè)置移動(dòng)后的位置

Location = mouseSet;

}

}

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

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

leftFlag = true; //點(diǎn)擊左鍵按下時(shí)標(biāo)注為true;

}

}

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

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

leftFlag = true; //點(diǎn)擊左鍵按下時(shí)標(biāo)注為true;

}

}

2.調(diào)用windows API

調(diào)用前需要添加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(); //釋放鼠標(biāo)捕捉

//發(fā)送左鍵點(diǎn)擊的消息至該窗體(標(biāo)題欄)

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

}

}

VB.NET怎么能拖動(dòng)無(wú)框窗體?請(qǐng)注意看補(bǔ)充,高手進(jìn)!

設(shè)置全局變量:

Dim drag As Boolean

Dim mousex As Integer

Dim mousey As Integer

假設(shè)你想拖動(dòng)的是Panel1控件,以及此控件上的 Label1(用于顯示標(biāo)題)和PictureBox4(用于顯示圖標(biāo)):

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怎么可以限制窗體不能被鼠標(biāo)隨便拖動(dòng)位置

很簡(jiǎn)單,通過(guò)WindowsAPI,刪除窗體菜單項(xiàng)就行了

首先在窗體類中聲明API:

Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr

Declare Function RemoveMenu Lib "user32" (ByVal lngHmenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer

其次聲明API參數(shù)常量:

Const MF_BYPOSITION As Integer = H400

然后在窗體類中寫(xiě)入過(guò)程:

Private Sub UserForm_Initialize_stopmove() '禁止窗體移動(dòng)

? Dim lngHwnd As IntPtr

? Dim lngHmenu As IntPtr

? lngHwnd = Me.Handle

? If lngHwnd 0 Then

? ? ? lngHmenu = GetSystemMenu(lngHwnd, False)

? ? ? RemoveMenu(lngHmenu, 0, MF_BYPOSITION) '這里的0代表菜單中從上往下數(shù)第一個(gè)菜單項(xiàng)

? End If

End Sub

Private Sub UserForm_Initialize_onmove() '恢復(fù)窗體移動(dòng)

? Dim lngHwnd As IntPtr

? Dim lngHmenu As IntPtr

? lngHwnd = Me.Handle

? If lngHwnd 0 Then

? ? ? lngHmenu = GetSystemMenu(lngHwnd, True)

RemoveMenu(lngHmenu, 0, MF_BYPOSITION) '這里的0與禁止代碼中的數(shù)值同步,原因時(shí)雖然表面上刪除了菜單項(xiàng),實(shí)則為隱藏了菜單項(xiàng),各個(gè)菜單的索引值并沒(méi)有變,所以0依然代表初始菜單的第一個(gè)菜單項(xiàng),即被刪除的那個(gè)菜單項(xiàng)

? End If

End Sub

然后如果你的窗口菜單是動(dòng)態(tài)變化的,建議聲明常數(shù):

Const MF_BYPOSITION As Integer = H0

然后使用相關(guān)的Windows功能的常數(shù)進(jìn)行刪除菜單。常數(shù)需要自行查看winuser.h頭文件

如果找不到該頭文件,可以看這里:網(wǎng)頁(yè)鏈接

其余信息詳見(jiàn)MSDN:網(wǎng)頁(yè)鏈接

最后說(shuō)一下,不建議前面網(wǎng)友說(shuō)的重寫(xiě)WndProc的方法,因?yàn)檫@樣攔截標(biāo)題欄點(diǎn)擊消息會(huì)導(dǎo)致窗體本身的菜單也無(wú)法顯示出來(lái),有損窗體功能,并且像雙擊左上角圖標(biāo)關(guān)閉窗體這樣的功能也會(huì)跟著攔截消息的操作一起被吞掉。


本文標(biāo)題:vb.net拖動(dòng)窗口,vbnet web窗體
URL地址:http://weahome.cn/article/dssjdes.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部