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
  • 相关阅读:
    ios更改UITabBarController背景以及选中背景图片的方法
    ios7 sdk 新特性
    AES加密算法原理
    iOS 获取手机的型号,系统版本,软件名称,软件版本
    iOS8中的UIActionSheet添加UIDatePicker后,UIDatePicker不显示问题
    iOS 8 定位失败问题
    利用CMake和OpenCV源代码生成Visual Studio工程
    dm8127前段采集和抓拍
    c++课程设计
    github安卓游戏
  • 原文地址:https://www.cnblogs.com/xiaoyinxxy/p/2997515.html
Copyright © 2011-2022 走看看