zoukankan      html  css  js  c++  java
  • 学习笔记 winForm move功能 与 drag 功能

    vb.Net WinForm move button function

    #Region "Move vb.net button"
        Private isDrag As Boolean = False
        Private downPoint As Point
        Private Sub Button2_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) _
           Handles Button2.MouseDown
            isDrag = True
            downPoint = e.Location
        End Sub
    
        Private Sub Button2_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) _
          Handles Button2.MouseMove
            If isDrag Then
                Button2.Location = e.Location + Button2.Location - downPoint
            End If
        End Sub
    
        Private Sub Button2_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) _
          Handles Button2.MouseUp
            isDrag = False
        End Sub
    #End Region

    vb.Net WinForm drag button function

    Set control's AllowDrag = True

    Set groupBox's AllowDrag = True

    #Region "drag vb.Net Button to GroupBox"
        Private Sub Button1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) _
            Handles Button1.MouseDown
            Button1.DoDragDrop(Button1, DragDropEffects.All)
        End Sub
    
        Private Sub GroupBox1_dragdrop(sender As Object, e As DragEventArgs) _
            Handles GroupBox1.DragDrop
            Button1.Left = e.X
            Button1.Top = e.Y
    
        End Sub
    
        Private Sub GroupBox1_DragOver(sender As Object, e As DragEventArgs) _
            Handles GroupBox1.DragOver
            e.Effect = DragDropEffects.All
        End Sub
    #End Region

    vb6 CodeArchitects.VB6Library.VB6CommandButton drag

    Set control's AllowDrag = True

    Set form's AllowDrag = True

     Dim CustomEditMode As Boolean = True
        Dim MouseY As Integer
        Dim MouseX As Integer
        Private Sub Button1_MouseDown(ByRef Button As Short, ByRef Shift As Short, ByRef x As Single, ByRef Y As Single) Handles Button1.MouseDown
            If CustomEditMode Then
                MouseY = Y
                MouseX = x
                Button1.Drag(1)
            End If
        End Sub
    
        Private Sub Button1_MouseUp(ByRef Button As Short, ByRef Shift As Short, ByRef x As Single, ByRef Y As Single) Handles Button1.MouseUp
            Button1.Drag(2)
        End Sub
    
        Private Sub Button1_DragDrop(ByRef Source As Control, ByRef x As Single, ByRef Y As Single) Handles Button1.DragDrop
            MouseY = (MouseY - Y)  
            MouseX = (MouseX - x) 
    
            Call Form_DragDrop(Source, Button1.Left, Button1.Top)
    
        End Sub
    
        Private Sub Form_DragDrop(ByRef Source As Control, ByRef x As Single, ByRef Y As Single) Handles MyBase.DragDrop
            If Not CustomEditMode Then 
                Exit Sub
            End If
            Source.Left = (x - MouseX) / 15
            Source.Top = (Y - MouseY) / 15
            Source.Enabled = True
    
        End Sub
  • 相关阅读:
    【css】所有的a标签设置为新窗口打开【原创】
    TP 3.1版本不支持 CONTROLLER_NAME
    关于TP 特殊页面伪静态规则的编写 研究实现
    larave PHP框架
    [转]git和github
    [转]mysql语句大全
    camera.swf?  提示  图片上传中请稍候,没任何报错
    mysql大小写敏感(默认为1,不敏感)
    数据cube的schema与sql的对应的关系
    MDX的实例讲解(排名前15的小例子)
  • 原文地址:https://www.cnblogs.com/xiaoyinxxy/p/2997515.html
Copyright © 2011-2022 走看看