0

With the following code i am able to move a panel inside my Windows-Form during run time.

    Private position As New Point()
    Private Sub Pnl_Osc_Settings_MouseMove(sender As Object, e As MouseEventArgs) Handles Pnl_Osc_Settings.MouseMove

        Dim p As Panel = CType(Pnl_Osc_Settings, Panel)

        If e.Button = MouseButtons.Left Then

            Dim mousePos As Point = Me.PointToClient(Control.MousePosition)

            If position.IsEmpty = True Then
                position = New Point(mousePos.X - p.Left, mousePos.Y - p.Top)
            End If
            p.Location = New Point(mousePos.X - position.X, mousePos.Y - position.Y)

        ElseIf Not position.IsEmpty = True Then

            position = New Point()

        End If


    End Sub

Is there an option to move this panel outside of my windows form? Many thanks in advance!

Hias
  • 45
  • 6
  • No, panels cannot be top-level windows. Use a borderless Form, and see this: https://stackoverflow.com/questions/1592876/make-a-borderless-form-movable – Cody Gray - on strike Jun 30 '21 at 07:37
  • No there isn't. You would have to create a separate form and put the `Panel` on that. You can then display that form in the current one, over it or outside it. – jmcilhinney Jun 30 '21 at 07:37

1 Answers1

1

impossible. However, if you use System.Runtime.Remoting.Channels.Ipc , you will be able to pass controls to other forms you create.

Think2826
  • 201
  • 1
  • 7
  • The purpose of Ipc is transporting messages between remote points as basic data types and not UI. UI’s needs a direct rendering by a top level window and cannot be transported by Ipc. In your shoes I’ll remove the answer :) – G3nt_M3caj Jun 30 '21 at 08:18
  • I may misunderstand the question. But. I can make a control as data and pass it to another form using ipc. It's unnecessary work. :) – Think2826 Jun 30 '21 at 08:56