当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > VB.NET 拖动无边框的窗体

ASP.NET
ASP.Net分页控件源码
Community Server专题一:概述Community Server
Community Server专题三:HttpModule
relaxlife.net发布一个自己开发的中文分词程序
RLCSS分词系统更新下载
asp.net获取SQL所有数据库名、所有表名、所有字段名
asp.net下获取Excel所有的工作表名称
Asp.Net常用函数
asp.net下用url重写URLReWriter实现任意二级域名的方法
在.NET中利用XMLHTTP下载文件的代码
在ASP.NET 中实现单点登录
c# .net 生成图片验证码的代码
asp.net中MD5 16位和32位加密函数
自己常用到的自定义公共类(已测试通过)
ASP.NET 2.0下随机读取Access记录的实现方法
.NET(C#)连接各类数据库代码-集锦
nunit使用指南之—NUnit Quick Start
ASP.NET中读取XML文件信息的4种方法与示例代码
asp.net中获取远程网页的内容之一(downmoon原创)
asp.net下获取远程网页的内容之二(downmoon原创)

ASP.NET 中的 VB.NET 拖动无边框的窗体


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 215 ::
收藏到网摘: n/a


  这是一个使用VB.net开发拖动无边框的窗体,以下为源代码,朋友们可以参考一下。



  '******************************************
  Private oOriginalRegion As Region = Nothing
  ' 用于窗体移动
  Private bFormDragging As Boolean = False
  Private oPointClicked As Point
  '******************************************
  Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
  Me.bFormDragging = True
  Me.oPointClicked = New Point(e.X, e.Y)
  End Sub
  '******************************************
  Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
  Me.bFormDragging = False
  End Sub
  '******************************************
  Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove

  If Me.bFormDragging Then
  Dim oMoveToPoint As Point
  ' 以当前鼠标位置为基础,找出目标位置
  oMoveToPoint = Me.PointToScreen(New Point(e.X, e.Y))
  ' 根据开始位置作出调整
  oMoveToPoint.Offset(Me.oPointClicked.X * -1, _
  (Me.oPointClicked.Y + _
  SystemInformation.CaptionHeight + _
  SystemInformation.BorderSize.Height) * -1)
  ' 移动窗体
  Me.Location = oMoveToPoint
  End If
  End Sub