Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.75 KB | None | 0 0
  1. Imports Telerik.WinControls
  2. Imports Telerik.WinControls.UI
  3. Imports System.IO
  4.  
  5. Public Class Form4
  6.  
  7.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.         ThemeResolutionService.ApplicationThemeName = "Office2010Blue"
  9.     End Sub
  10.  
  11.    
  12.  
  13.     Private btn As Button ' this is a reference object
  14.     Private ptX, ptY As Integer
  15.     Private drag As Boolean
  16.  
  17.     Private Sub nodebtn_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  18.         If e.Button = MouseButtons.Left Then
  19.             drag = True
  20.             btn = CType(sender, Button)
  21.             ptX = e.X : ptY = e.Y
  22.         End If
  23.     End Sub
  24.  
  25.     Private Sub nodebtn_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  26.         If drag Then
  27.             btn.Location = New Point(btn.Location.X + e.X - ptX, btn.Location.Y + e.Y - ptY)
  28.             Me.Refresh()
  29.         End If
  30.     End Sub
  31.  
  32.     Private Sub nodebtn_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
  33.         drag = False
  34.     End Sub
  35.  
  36.     Private Sub nodebtn_MouseClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  37.        
  38.  
  39.     End Sub
  40.  
  41.     Private Sub Form2_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseHover
  42.  
  43.     End Sub
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.     Private Sub Form2_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
  52.  
  53.     End Sub
  54.  
  55.     Private Sub Form2_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
  56.  
  57.     End Sub
  58.  
  59.     Private Sub Form2_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
  60.  
  61.     End Sub
  62.  
  63.     Private Sub CreateFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateFileToolStripMenuItem.Click
  64.         Dim b As New Button
  65.         Dim LocalMousePosition As Point
  66.         LocalMousePosition = PointToClient(Cursor.Position)
  67.         b.Text = Nothing
  68.         b.FlatStyle = FlatStyle.Flat
  69.         b.Size = New Point(33, 23)
  70.         b.BackColor = Color.Transparent
  71.         b.BackgroundImage = My.Resources.file_extension_bin
  72.         b.BackgroundImageLayout = ImageLayout.Stretch
  73.         b.Location = New Point(LocalMousePosition.X, LocalMousePosition.Y)
  74.         b.FlatAppearance.BorderSize = 0
  75.         AddHandler b.MouseDown, AddressOf nodebtn_MouseDown
  76.         AddHandler b.MouseMove, AddressOf nodebtn_MouseMove
  77.         AddHandler b.MouseUp, AddressOf nodebtn_MouseUp
  78.         AddHandler b.MouseClick, AddressOf nodebtn_MouseClick
  79.         Me.Controls.Add(b)
  80.     End Sub
  81.  
  82. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement