Cryptonic (04-28-2013),EliteDawn (05-02-2013),rileyjstrickland (02-08-2013)
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:
Credits: Me and AaronCode:ReleaseCapture() SendMessage(Handle, &HA1, &H2, 0)
Cryptonic (04-28-2013),EliteDawn (05-02-2013),rileyjstrickland (02-08-2013)
Works nicely
DawgiiStylz (02-07-2013),EliteDawn (05-02-2013)
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
Successful Sales: 1@The403
@sundy42
Scammed: 1@wZ. Gali
Favorite Quotes:
abuckau907 (02-09-2013)
EliteDawn (05-02-2013)
If You Like My Releases, Hit The Thanks button!
Follow the rules.
Successful Purchases: 2
Successful Sales: 1@The403
@sundy42
Scammed: 1@wZ. Gali
Favorite Quotes:
EliteDawn (05-02-2013)
Well.
I use:
It's better and easier to 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
And that what "you (... -.- Sure ...)" have RELEASED here I find 1000x in Google.
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'
Cryptonic (04-28-2013)
heheCode:<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