拖动无标题的窗体(vb.net & c#)
2006-10-13 09:17
537 查看
c#
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern int ReleaseCapture();
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
vb.net
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public Declare Function ReleaseCapture Lib "user32.dll" Alias "ReleaseCapture" () As Integer
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
If e.Button = MouseButtons.Left Then
' 为当前的应用程序释放鼠标捕获
ReleaseCapture()
' 发送消息,让系统误以为你在标题拦上按下鼠标
SendMessage(Me.Handle.ToInt32, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0)
End If
End Sub
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern int ReleaseCapture();
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
vb.net
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Public Declare Function ReleaseCapture Lib "user32.dll" Alias "ReleaseCapture" () As Integer
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
If e.Button = MouseButtons.Left Then
' 为当前的应用程序释放鼠标捕获
ReleaseCapture()
' 发送消息,让系统误以为你在标题拦上按下鼠标
SendMessage(Me.Handle.ToInt32, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0)
End If
End Sub
相关文章推荐
- vb.net实现无标题栏窗体可拖动
- vb.net实现无标题栏窗体可拖动
- c#拖动无标题窗体
- C#无标题栏窗体鼠标拖动
- TaskbarNotifier: 可换肤的 MSN Messenger-like 风格窗体( C# & VB.NET)
- vb.net 与c# 窗体绘制水晶按钮图形
- vb.net 与c# 窗体绘制水晶按钮图形
- VB.NET 拖动无边框的窗体- -
- 如何使用C#或者VB.NET读写Access数据库的标题(Caption)、描述(Description)等字段信息?
- 解决WinForm(C#)中MDI子窗体最大化的问题(VB.net中也适用)
- C#无标题栏窗体鼠标拖动
- VB.NET 拖动无边框的窗体
- C#窗体无标题栏拖动
- C#无标题栏窗体鼠标拖动
- VB.NET拖动无边框窗体API
- c# 在WinForm 窗体间传递信息(转换为VB.net)
- C#实现无标题栏窗体的拖动
- [CodeProject每日一荐] TaskbarNotifier: 可换肤的 MSN Messenger-like 风格窗体( C# & VB.NET)
- C#无标题栏窗体鼠标拖动
- VB.NET拖动无边框窗体API