Results 1 to 5 of 5

Thread: [HELP] Move A Form

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2009
    Location
    Canada/Quebec
    Posts
    54

    [HELP] Move A Form

    I want to be able to drag the form by click on the form.... not by clicking on the bar...

    The formborderstyle is at None...
    sorry for my english
    Last edited by DaneX; Jul 9th, 2009 at 02:34 PM.
    Learning VB2008
    Developer DaneX

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [HELP] Move A Form

    Try this:

    Code:
    Private Const WM_NCLBUTTONDOWN As Integer = &HA1S
    Private Const HTCAPTION As Integer = &H2
    
    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
         Me.Capture = False
         Dim msg As Message = Message.Create(Me.Handle, WM_NCLBUTTONDOWN, New IntPtr(HTCAPTION), IntPtr.Zero)
         Me.DefWndProc(msg)
    End Sub
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: [HELP] Move A Form

    Take a look at my signature, there's a link to a codebank submission for moving and resizing a Borderless Form using API calls. The resizing bit is a little complicated, but the moving part is really easy.

    EDIT
    After taking a second look, it seems that stanav's code does exactly the same, he just calls the required functions in a different way

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2009
    Location
    Canada/Quebec
    Posts
    54

    Re: [HELP] Move A Form

    OH! ty stanav! it work great!
    Learning VB2008
    Developer DaneX

  5. #5
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [HELP] Move A Form

    Quote Originally Posted by DaneX View Post
    OH! ty stanav! it work great!
    I only give good code. LOL!
    And you're welcomed.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width