Ciao,
ho un piccolo problemino sulla creazione degli oggetti a run time con immediato drag&drop.
Sono riuscito a creare l'oggetto, ad esempio un pulsante e quindi successivamente a muoverlo.
Il mio obiettivo sarebbe quello di effettuare l'immediato spostamento dell'oggetto nel momento in cui lo creo,è possibile?
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureTextBox.MouseDown
Dim b As New Button
b.Text = "Pulsante" & counter.ToString
b.Location = New Point(PictureTextBox.Location.X, PictureTextBox.Location.Y)
counter += 1
AddHandler b.Click, AddressOf btns_click
AddHandler b.MouseDown, AddressOf btns_MouseDown
Me.Controls.Add(b)
End Sub
Private Sub btns_click(ByVal sender As Object, ByVal e As EventArgs)
MsgBox(DirectCast(sender, Button).Text & " clicked")
End Sub
Private Sub btns_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim btn As Button = DirectCast(sender, Button)
btn.Capture = False
Const WM_NCLBUTTONDOWN As Integer = &HA1
Const HTCAPTION As Integer = &H2
Dim msg As Message =
Message.Create(btn.Handle, WM_NCLBUTTONDOWN,
New IntPtr(HTCAPTION), IntPtr.Zero)
Me.DefWndProc(msg)
End Sub
Grazie