EvilZone

Programming and Scripting => .NET Framework => Topic started by: uNk on March 31, 2011, 11:04:09 PM

Title: [VB.NET] Move borderless forms (Good for selfmade skins)
Post by: uNk on March 31, 2011, 11:04:09 PM
Put this code after "Public Class (Your Form name) line"

Code: [Select]
   Dim Point As New System.Drawing.Point()
    Dim U, N As Integer
    Private Sub Main_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
        If e.Button = MouseButtons.Left Then
            Point = Control.MousePosition
            Point.X = Point.X - (U)
            Point.Y = Point.Y - (N)
            Me.Location = Point
        End If
    End Sub
    Private Sub Main_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        U = Control.MousePosition.X - Me.Location.X
        N = Control.MousePosition.Y - Me.Location.Y
    End Sub
    Private Sub Sub_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If e.Button = MouseButtons.Left Then
            Point = Control.MousePosition
            Point.X = Point.X - (U)
            Point.Y = Point.Y - (N)
            Me.Location = Point
        End If
    End Sub
    Private Sub Sub_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        U = Control.MousePosition.X - Me.Location.X
        N = Control.MousePosition.Y - Me.Location.Y
    End Sub

You may also add these tags so you can minimize/hide the code snippet in case it confuses you:

Code: [Select]
#Region "what ever"
CODE HERE
#End Region
 

The results of this is that you can move forms that has the option "FormBorderStyle: None" chosen so you can make your own Photoshop background and add your own buttons like this:


(http://ploader.net/files/0c7f21674b2e64f08db6aa3be3fa3d2b.png)
Title: Re: [VB.NET] Move borderless forms (Good for selfmade skins)
Post by: Huntondoom on March 31, 2011, 11:28:26 PM
yes Thanks A lot!
I was busy making an own Form but I failed at some point, so this will be great :P
do you have any snippets on resizing the Custom Form?
Title: Re: [VB.NET] Move borderless forms (Good for selfmade skins)
Post by: ande on April 01, 2011, 12:13:04 PM
Neat, this can easely be added to a custom border thingy to, just make a panel or transparent button or something and add this code to its mouseup/down :)
Title: Re: [VB.NET] Move borderless forms (Good for selfmade skins)
Post by: Huntondoom on April 01, 2011, 02:37:52 PM
Neat, this can easely be added to a custom border thingy to, just make a panel or transparent button or something and add this code to its mouseup/down :)
Okay Thanks for the advice, something may appear in the Zone Releases :P (in the next few days)