none
How do you move items in visual basic

    Question

  • I actually have to questions related to the same subject. First, I would like to know how to drag and drop items from a toolbox, for example, and onto a control coded to accept them.

    My second question is how could I move a form, with the mouse, that is completely customised.

    Thanks!

    • Moved by nobugzMVP, Moderator Saturday, August 08, 2009 7:16 PM not a clr q (From:Common Language Runtime)
    Saturday, August 08, 2009 7:07 PM

Answers

  • Hello Developer911,

    Take a look at the following link for drag and drop:

    http://www.vb-helper.com/howto_net_drag_drop.html

    What do you mean by "how could I move a form, with the mouse, that is completely customised"?  Are you saying there is no longer a TitleBar on your Form?  If so, all you need to do is use this API:

        Const WM_NCHITTEST As Integer = &H84
        Const HTCLIENT As Integer = &H1
        Const HTCAPTION As Integer = &H2
        Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
            Select Case m.Msg
                Case WM_NCHITTEST
                    MyBase.WndProc(m)
                    If m.Result = HTCLIENT Then m.Result = HTCAPTION
                Case Else
                    'Make sure you pass unhandled messages back to the default message handler.  
                    MyBase.WndProc(m)
            End Select
        End Sub

    Best regards,
    Adjutor
    • Marked as answer by Xingwei Hu Friday, August 14, 2009 3:15 AM
    Saturday, August 08, 2009 9:06 PM

All replies

  • Hello Developer911,

    Take a look at the following link for drag and drop:

    http://www.vb-helper.com/howto_net_drag_drop.html

    What do you mean by "how could I move a form, with the mouse, that is completely customised"?  Are you saying there is no longer a TitleBar on your Form?  If so, all you need to do is use this API:

        Const WM_NCHITTEST As Integer = &H84
        Const HTCLIENT As Integer = &H1
        Const HTCAPTION As Integer = &H2
        Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
            Select Case m.Msg
                Case WM_NCHITTEST
                    MyBase.WndProc(m)
                    If m.Result = HTCLIENT Then m.Result = HTCAPTION
                Case Else
                    'Make sure you pass unhandled messages back to the default message handler.  
                    MyBase.WndProc(m)
            End Select
        End Sub

    Best regards,
    Adjutor
    • Marked as answer by Xingwei Hu Friday, August 14, 2009 3:15 AM
    Saturday, August 08, 2009 9:06 PM
  • ProgrammingPages.net
    Best Programming Resources and Source Code Examples for Java, Php, Visual Basic, C++ ,Asp, Python, Javascript, Ada, Cobol ,C, C#, Delphi, Fortran, Logo, Ruby, Xml.
    http://www.programmingpages.net


    Monday, June 13, 2011 12:14 PM