Results 1 to 13 of 13
  1. #1
    Honesty is an expensive gift do not expect it from cheap people!
    MPGH Member
    Matroix73's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    706
    Reputation
    42
    Thanks
    5,624
    My Mood
    Confused

    Perfect native borderless form moving using any control

    Alright guys,

    I've finally found a way to create PERFECT borderless form moving that uses the NATIVE Windows Form moving method. The other method where it just checks if your mouse is down and moves with your mouse is BUGGY. Load up a form then shake your mouse around while moving the it and you will see your mouse has moved it's position on the form.

    I was hesitant to release this, but here you go. Don't leech it.

    Put this at the top of your code:
    Code:
    Imports System.Runtime.InteropServices


    Put this inside your class, not inside a sub:
    Code:
    <DllImport("user32.dll")> _
    Public Shared Function ReleaseCapture() As Boolean
    End Function
    <DllImport("user32.dll")> _
    Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    End Function

    Put this in your control's Click, MouseDown, and MouseMove events:
    Code:
    ReleaseCapture()
    SendMessage(Handle, &HA1, &H2, 0)
    Credits: Me and Aaron

  2. The Following 3 Users Say Thank You to Matroix73 For This Useful Post:

    Cryptonic (04-28-2013),EliteDawn (05-02-2013),rileyjstrickland (02-08-2013)

  3. #2
    DawgiiStylz's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Dawg House
    Posts
    7,811
    Reputation
    219
    Thanks
    2,896
    My Mood
    Tired
    Works nicely

  4. #3
    Threadstarter
    Honesty is an expensive gift do not expect it from cheap people!
    MPGH Member
    Matroix73's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    706
    Reputation
    42
    Thanks
    5,624
    My Mood
    Confused
    Quote Originally Posted by DawgiiStylz View Post
    Works nicely
    Great! I'm glad to help

  5. The Following 2 Users Say Thank You to Matroix73 For This Useful Post:

    DawgiiStylz (02-07-2013),EliteDawn (05-02-2013)

  6. #4
    Threadstarter
    Honesty is an expensive gift do not expect it from cheap people!
    MPGH Member
    Matroix73's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    706
    Reputation
    42
    Thanks
    5,624
    My Mood
    Confused
    Please Credit me when you use it!

  7. #5
    rileyjstrickland's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Florida
    Posts
    649
    Reputation
    90
    Thanks
    4,008
    My Mood
    Relaxed
    Quote Originally Posted by Matroix73 View Post
    Please Credit me when you use it!
    Credit you for something that comes with the native Windows API?
    No.
    Thank you for pointing this feature out?
    Sure, why not, but forcing someone to credit you for telling them about Window's native features is pretty leechy, since Microsoft coded said features in the original C/C++/what ever windows was compiled in.

    I'm not saying this to be mean, but to point out that you do not "personally" own the code, as it's just using the API which does all the work.

    If You Like My Releases, Hit The Thanks button!
    Follow the rules.

    Successful Purchases: 2
    @The403
    @sundy42
    Successful Sales: 1
    @wZ. Gali
    Scammed: 1

    Favorite Quotes:
    Quote Originally Posted by Doc View Post
    Who cares about simplified mandarin. The only problem here is that Cantonese (and Hokkien) is no longer being taught, but guess what, times change. There have been thousands of languages that have been lost to the ages, you'd be pissing in the wind to try and stop that.

  8. The Following User Says Thank You to rileyjstrickland For This Useful Post:

    abuckau907 (02-09-2013)

  9. #6
    Threadstarter
    Honesty is an expensive gift do not expect it from cheap people!
    MPGH Member
    Matroix73's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    706
    Reputation
    42
    Thanks
    5,624
    My Mood
    Confused
    Quote Originally Posted by rileyjstrickland View Post
    Credit you for something that comes with the native Windows API?
    No.
    Thank you for pointing this feature out?
    Sure, why not, but forcing someone to credit you for telling them about Window's native features is pretty leechy, since Microsoft coded said features in the original C/C++/what ever windows was compiled in.

    I'm not saying this to be mean, but to point out that you do not "personally" own the code, as it's just using the API which does all the work.
    well, so if I force someone to credit me, so I'd make this in private, or even release it in private (PM me for the code)
    and crediting me is your own choice...

  10. The Following User Says Thank You to Matroix73 For This Useful Post:

    EliteDawn (05-02-2013)

  11. #7
    rileyjstrickland's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Florida
    Posts
    649
    Reputation
    90
    Thanks
    4,008
    My Mood
    Relaxed
    Quote Originally Posted by Matroix73 View Post
    well, so if I force someone to credit me, so I'd make this in private, or even release it in private (PM me for the code)
    and crediting me is your own choice...
    That sentence was an utter failure.

    Please type logical, coherent, English sentences.

    If You Like My Releases, Hit The Thanks button!
    Follow the rules.

    Successful Purchases: 2
    @The403
    @sundy42
    Successful Sales: 1
    @wZ. Gali
    Scammed: 1

    Favorite Quotes:
    Quote Originally Posted by Doc View Post
    Who cares about simplified mandarin. The only problem here is that Cantonese (and Hokkien) is no longer being taught, but guess what, times change. There have been thousands of languages that have been lost to the ages, you'd be pissing in the wind to try and stop that.

  12. #8
    shindereki's Avatar
    Join Date
    Feb 2013
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    thank you.......

  13. #9
    Threadstarter
    Honesty is an expensive gift do not expect it from cheap people!
    MPGH Member
    Matroix73's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    706
    Reputation
    42
    Thanks
    5,624
    My Mood
    Confused
    Quote Originally Posted by shindereki View Post
    thank you.......
    You welcome.

  14. The Following User Says Thank You to Matroix73 For This Useful Post:

    EliteDawn (05-02-2013)

  15. #10
    Zorndel's Avatar
    Join Date
    Apr 2013
    Gender
    male
    Posts
    30
    Reputation
    10
    Thanks
    945
    My Mood
    Fine
    Well.

    I use:
    Code:
     Declare Function ReleaseCapture Lib "user32" () As IntPtr
        Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As IntPtr, ByVal wParam As IntPtr, ByRef lParam As Object) As IntPtr
        Const WM_NCLBUTTONDOWN = &HA1
        Const HTCAPTION = 2
    
        Private Sub MovePosition(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Form1.MouseDown, Label1.MouseDown', ...
            ReleaseCapture()
            SendMessage(Handle, CType(WM_NCLBUTTONDOWN, IntPtr), CType(HTCAPTION, IntPtr), 2)
        End Sub
    It's better and easier to use.
    And that what "you (... -.- Sure ...)" have RELEASED here I find 1000x in Google.

  16. #11
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    It's more of thank you for your contribution to this section.

  17. #12
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Quote Originally Posted by PepsiXHacker View Post
    It's more of thank you for your contribution to this section.
    Tho, it do belong here:
    https://www.mpgh.net/forum/33-visual-...ets-vault.html

    'Bump allowed due to low activity'

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  18. The Following User Says Thank You to Jorndel For This Useful Post:

    Cryptonic (04-28-2013)

  19. #13
    DawgiiStylz's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Dawg House
    Posts
    7,811
    Reputation
    219
    Thanks
    2,896
    My Mood
    Tired
    Code:
    <DllImport("user32.dll")> _
        Public Shared Function ReleaseCapture() As Boolean
        End Function
    
    
        <DllImport("user32.dll")> _
        Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
        End Function
    
    
        Private Const WM_NCLBUTTONDOWN As Integer = &HA1
        Private Const HTCAPTION As Integer = 2
    
       Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
            If e.Button = Windows.Forms.MouseButtons.Left And Me.WindowState <> FormWindowState.Maximized Then
                MoveForm()
            End If
        End Sub
    
    
        Private Sub MoveForm()
            ReleaseCapture()
            SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
        End Sub
    hehe

Similar Threads

  1. [Tutorial] Using User Controls as a Form Replacement
    By DawgiiStylz in forum Visual Basic Programming
    Replies: 1
    Last Post: 07-19-2012, 04:36 AM
  2. TUT]How to move a borderless form[TUT
    By XGelite in forum Visual Basic Programming
    Replies: 7
    Last Post: 11-14-2009, 03:11 PM
  3. Replies: 17
    Last Post: 03-23-2009, 11:20 PM
  4. Using a Controller ingame
    By SuperDOoche in forum Combat Arms Hacks & Cheats
    Replies: 25
    Last Post: 08-25-2008, 05:52 PM