Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Move And Resize - Borderless Form

🙂 https://hackforums.net/showthread.php?tid=4389523

[Image: cb9cdf8d2763d91f7f31a43355c77cf1.png]

[Image: 7db799cb0fe2deff3cd1546e9893cd3c.png]

😝
Doesn't work, mine's better.

Code
Private resizeFlag As Boolean = False
    Private mouseDownLocation As Point
    Private resizeNStop As Boolean = False
    Private resizeNSbottom As Boolean = False
    Private resizeWEleft As Boolean = False
    Private resizeWEright As Boolean = False
    Private FormPanel As New Panel

Code
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
      AddHandler Me.MouseMove, AddressOf myMouseMove
      AddHandler Me.MouseUp, AddressOf myMouseUp
      AddHandler Me.MouseDown, AddressOf myMouseDown
      FormPanel.BorderStyle = BorderStyle.FixedSingle
      FormPanel.Dock = DockStyle.Fill
      AddHandler FormPanel.MouseDown, AddressOf myMouseDown
      AddHandler FormPanel.MouseUp, AddressOf myMouseUp
      AddHandler FormPanel.MouseMove, AddressOf myMouseMove
      Me.Controls.Add(FormPanel)
      Dim statusBar As New StatusBar
      statusBar.Dock = DockStyle.Bottom
      AddHandler statusBar.MouseDown, AddressOf myMouseDown
      AddHandler statusBar.MouseUp, AddressOf myMouseUp
      AddHandler statusBar.MouseMove, AddressOf myMouseMove
      FormPanel.Controls.Add(statusBar)
      Dim lblTitle As New Label
      lblTitle.Text = "Form1"
      lblTitle.TextAlign = ContentAlignment.MiddleCenter
      lblTitle.AutoSize = False
      lblTitle.Dock = DockStyle.Top
      AddHandler lblTitle.MouseDown, AddressOf myMouseDown
      AddHandler lblTitle.MouseUp, AddressOf myMouseUp
      AddHandler lblTitle.MouseMove, AddressOf myMouseMove
      FormPanel.Controls.Add(lblTitle)

Code
Private Sub myMouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
      If (e.Button = Windows.Forms.MouseButtons.Left) Then
      If Not resizeFlag Then
      Me.Location += e.Location - mouseDownLocation
      Else
      If resizeNSbottom Then
      If (CType(sender, Control).Dock = DockStyle.None) Or (CType(sender, Control).Dock = DockStyle.Fill) Then
      Me.Height = e.Y
      Else
      Me.Height += e.Y - mouseDownLocation.Y
      End If
      End If
      If resizeNStop Then
      Dim previousTop As Integer = Me.Top
      Me.Top += e.Y - mouseDownLocation.Y
      Me.Height += previousTop - Me.Top
      End If
      If resizeWEright Then
      Me.Width = e.X
      End If
      If resizeWEleft Then
      Dim previousLeft As Integer = Me.Left
      Me.Left += e.X - mouseDownLocation.X
      Me.Width += previousLeft - Me.Left
      End If
      End If
      Else
      setCursor()
      End If
    End Sub
    Private Sub myMouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
      If e.Button = Windows.Forms.MouseButtons.Left Then
      If (resizeFlag = False) Then
      If checkResize() Then
      resizeFlag = True
      End If
      setCursor()
      End If
      mouseDownLocation = e.Location
      End If
    End Sub
    Private Sub myMouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
      resizeFlag = False
      resizeNSbottom = False
      resizeNStop = False
      resizeWEright = False
      resizeWEleft = False
    End Sub
    Private Sub setCursor()
      Cursor = Cursors.Default
      If (Cursor.Position.X >= Me.Left + Me.Width - 10) Then
      Cursor = Cursors.SizeWE
      End If
      If (Cursor.Position.X <= Me.Left + 10) And (Cursor.Position.X >= Me.Left) Then
      Cursor = Cursors.SizeWE
      End If
      If (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 10) Then
      Cursor = Cursors.SizeNS
      End If
      If (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 10) Then
      Cursor = Cursors.SizeNS
      End If
      If (Cursor.Position.X >= Me.Left + Me.Width - 9) And (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 9) Then
      Cursor = Cursors.SizeNESW
      End If
      If (Cursor.Position.X >= Me.Left + Me.Width - 9) And (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 9) Then
      Cursor = Cursors.SizeNWSE
      End If
      If (Cursor.Position.X <= Me.Left + 9) And (Cursor.Position.X >= Me.Left) And (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 9) Then
      Cursor = Cursors.SizeNESW
      End If
      If (Cursor.Position.X <= Me.Left + 9) And (Cursor.Position.X >= Me.Left) And (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 9) Then
      Cursor = Cursors.SizeNWSE
      End If
    End Sub

    Private Function checkResize() As Boolean
      Cursor = Cursors.Cross
      If (Cursor.Position.X >= Me.Left + Me.Width - 9) And (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 9) Then
      resizeWEright = True
      resizeNStop = True
      Return True
      End If
      If (Cursor.Position.X >= Me.Left + Me.Width - 9) And (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 9) Then
      resizeWEright = True
      resizeNSbottom = True
      Return True
      End If
      If (Cursor.Position.X <= Me.Left + 9) And (Cursor.Position.X >= Me.Left) And (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 9) Then
      resizeWEleft = True
      resizeNSbottom = True
      Return True
      End If
      If (Cursor.Position.X <= Me.Left + 9) And (Cursor.Position.X >= Me.Left) And (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 9) Then
      resizeWEleft = True
      resizeNStop = True
      Return True
      End If
      If (Cursor.Position.X >= Me.Left + Me.Width - 10) Then
      resizeWEright = True
      Return True
      End If
      If (Cursor.Position.X <= Me.Left + 10) And (Cursor.Position.X >= Me.Left) Then
      resizeWEleft = True
      Return True
      End If
      If (Cursor.Position.Y >= Me.Top) And (Cursor.Position.Y <= Me.Top + 10) Then
      resizeNStop = True
      Return True
      End If
      If (Cursor.Position.Y <= Me.Top + Me.Height) And (Cursor.Position.Y >= Me.Top + Me.Height - 10) Then
      resizeNSbottom = True
      Return True
      End If
      Return False
    End Function

I wonder what you will complain about.
(Nov 27, 2014 11:39 AM)AEDEAD Wrote:  Doesn't work, mine's better.

I wonder what you will complain about.

"Better"? Your code is soo messy and so long for such as simple task.
(Nov 27, 2014 12:15 PM)Cornflower Blue இڿڰۣ-ڰۣ— Wrote:  "Better"? Your code is soo messy and so long for such as simple task.

Are you fucking kidding me. Look at the code, there is no possible way to make it shorter doing what I did. >_> If you want to say something like that, PROVE IT. Nuf said.
(Nov 27, 2014 12:33 PM)AEDEAD Wrote:  Are you fucking kidding me. Look at the code, there is no possible way to make it shorter doing what I did. >_> If you want to say something like that, PROVE IT. Nuf said.

[Image: cb9cdf8d2763d91f7f31a43355c77cf1.png]

Done.
(Nov 27, 2014 02:30 PM)Cornflower Blue இڿڰۣ-ڰۣ— Wrote:  [Image: cb9cdf8d2763d91f7f31a43355c77cf1.png]

Done.

Erm, you blatantly just leeched that from this thread. People like you ruin this section you know that?
(Nov 27, 2014 03:07 PM)AEDEAD Wrote:  Erm, you blatantly just leeched that from this thread. People like you ruin this section you know that?

You said prove it, he did. He never claimed it as his own, or said that he made it. Why must you troll and flame? And why do you want my source if you can code something like this?
(Nov 27, 2014 03:50 PM)PapaBeans Wrote:  You said prove it, he did. He never claimed it as his own, or said that he made it. Why must you troll and flame? And why do you want my source if you can code something like this?

it was implied he should have done his own movable and RESIZING bordless form code. Not simply copy paste the IMAGE the op posted as the thread.

I don't care about your source now that you want to be a blatant troll. Please do not this thread unless you have something useful to say. Thank you.
(Nov 27, 2014 12:33 PM)AEDEAD Wrote:  Are you fucking kidding me. Look at the code, there is no possible way to make it shorter doing what I did. >_> If you want to say something like that, PROVE IT. Nuf said.

Dont listen to him, worked fine for me.

(Nov 27, 2014 11:32 AM)Only3 Wrote:  🙂 https://hackforums.net/showthread.php?tid=4389523

[Image: cb9cdf8d2763d91f7f31a43355c77cf1.png]

😝
Thank you worked very well +1 OP


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Lor‌dJul 7, 2020 12:52 PM 19 404 Jul 7, 2020 12:52 PM
Last Post: n0$f3ratu$
[C#] by KingSeaNov 22, 2018 11:58 AM 7 226 Nov 22, 2018 11:58 AM
Last Post: passwords
[.NET] by EffexionOct 21, 2017 05:57 AM 2 198 Oct 21, 2017 05:57 AM
Last Post: Effexion