I used this code to maximize and restore my custom form. But when the form is maximized, it still remains draggable, I use a timer to drag the form.
Private Sub btnMaximize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMaximize.Click, lblTitle.MouseDoubleClick Dim maximizeHeight As Integer = Screen.PrimaryScreen.WorkingArea.Height Dim maximizeWidth As Integer = Screen.PrimaryScreen.WorkingArea.Width Dim maximizeLocation As Point = New Point(0, 0) Dim fullscreen As Boolean = FalseIf Me.Height = maximizeHeight Or Me.Width = maximizeWidth Or Me.Location = maximizeLocation Then fullscreen = True Else fullscreen = False End If If fullscreen = True Then Me.Size = New Size(1000, 500) Me.Left = (Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2 Me.Top = (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2 ElseIf fullscreen = False Then Me.Location = New Point(0, 0) Me.Size = New Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height) End If End Sub<code>
Private Sub pnlBar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblTitle.MouseDown MoveTmr.Start() refpositions() End Sub
Private Sub MoveTmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MoveTmr.Tick Me.Location = oloc - ocur + System.Windows.Forms.Cursor.Position refpositions() End Sub Private Sub pnlBar_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblTitle.MouseUp MoveTmr.Stop() refpositions() End Sub Private Sub RszTmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles RszTmr.Tick Me.Size = appSize - curPos + Cursor.Position refpositions() End Sub