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

推荐订阅源

T
Tor Project blog
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
I
InfoQ
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
人人都是产品经理
人人都是产品经理
美团技术团队
B
Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Last Week in AI
Last Week in AI
TaoSecurity Blog
TaoSecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
T
Threatpost
H
Heimdal Security Blog
爱范儿
爱范儿
博客园_首页
SecWiki News
SecWiki News
腾讯CDC
大猫的无限游戏
大猫的无限游戏
GbyAI
GbyAI
The Register - Security
The Register - Security
N
News | PayPal Newsroom
Recent Commits to openclaw:main
Recent Commits to openclaw:main
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Security Latest
Security Latest
A
Arctic Wolf
P
Privacy & Cybersecurity Law Blog
T
The Blog of Author Tim Ferriss
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
量子位
Schneier on Security
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
Attack and Defense Labs
Attack and Defense Labs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Webroot Blog
Webroot Blog
C
Check Point Blog
Y
Y Combinator Blog
T
The Exploit Database - CXSecurity.com
aimingoo的专栏
aimingoo的专栏
I
Intezer
博客园 - 叶小钗
Cisco Talos Blog
Cisco Talos Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
小众软件
小众软件

博客园 - 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 拖动时,窗口就会移动。