惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
P
Proofpoint News Feed
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
F
Fortinet All Blogs
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
C
Check Point Blog
Microsoft Azure Blog
Microsoft Azure Blog
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
美团技术团队
D
Docker
博客园 - Franky
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

博客园 - Dawnxu

修改的Flash + ASP.NET 拍照程序 AjaxPro在Windows 2000 server下不能正常使用的解决方案 MSN 8.0 邀请函! RAR 命令 新版XNet.SqlHelper 很不错的Windows 控件 Developer Express Inc.NET 61条面向对象设计的经验原则 两个WEB程序之间的通信 本人还有50份GMail邀请函,要的请留言! 关于俱乐部活动的个人想法! 操作MS SQL Server 存储过程的类(外加ASP.NET MessageBox类) 修改的一个Title提示 大学毕业了再看你会后悔一辈子的 妙用Asp.Net中的HttpHandler [转载]ASP.NET分页的处理方式 [转载]ASP.NET开发经验积累 WINDOWS2000开机硬盘自动共享 [转载]无组件上传程序ASP.NET版 C#实现的根据年月日计算星期几的函数
鼠标按住任意控件拖动窗口
Dawnxu · 2005-12-21 · via 博客园 - Dawnxu

Imports System.Drawing.Point

Public Class Move
    
Private WithEvents control As System.Windows.Forms.Control
    
Private mouse_offset As Point
    
Private frm As Form

    
Public Sub New(ByVal theControl As System.Windows.Forms.Control, ByVal theForm As Form)
        
Me.control = theControl '鼠标拖动的控件
        Me.frm = theForm '要移动的窗口
    End Sub

    
Private Sub GroupControl1_MouseDown(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs) Handles control.MouseDown
        mouse_offset 
= New Point(e.X, e.Y)
    
End Sub


    
Private Sub GroupControl1_MouseMove(ByVal sender As ObjectByVal e As System.Windows.Forms.MouseEventArgs) Handles control.MouseMove

        
If (e.Button = MouseButtons.Left Or e.Button = MouseButtons.Right) Then
            
Dim mousePos As Point = frm.MousePosition
            
'获得鼠标偏移量
            mousePos.Offset(-mouse_offset.X, -mouse_offset.Y)
            
'设置窗体随鼠标一起移动
            frm.Location = mousePos
        
End If

    
End Sub

End Class

使用:

在窗口加载时:

Move move = new Move(this.label1,this)
这样鼠标按住 label1 拖动时,窗口就会移动。