Private Sub frmSearchTicket_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Move '************************************************************************ ' Procedure/Function: frmSearchTicket_Move() ' Author: Ben Santiago ' Last Revision: 11/17/2005 ' Description: ' Limit movement of search form to that of the main MDI form area. '************************************************************************ '*************************************** ' If Main MDI Form Minimized, Do Not Attempt Move '*************************************** If objMainForm.WindowState = FormWindowState.Minimized Then Exit Sub End If '*************************************** ' Check Top ' +44 = Used To Compensate For Title Bar & Menu '*************************************** If Me.Top <= objMainForm.Top + 44 Then Me.Top = objMainForm.Top + 44 End If '*************************************** ' Check Left ' +7 = Used To Compensate For Left Border of MDI Parent '*************************************** If Me.Left <= objMainForm.Left + 7 Then Me.Left = objMainForm.Left + 7 End If '*************************************** ' Check Right ' -7 = Used To Compensate For Right Border of MDI Parent '*************************************** If Me.Left + Me.Width > (objMainForm.Left + objMainForm.Width) - 7 Then Me.Left = (objMainForm.Left + objMainForm.Width) - Me.Width - 7 End If '*************************************** ' Check Bottom ' -7 = Used To Compensate For Bottom Border of MDI Parent '*************************************** If Me.Top + Me.Height > (objMainForm.Top + objMainForm.Height) - objMainForm.sbMainStatus.Height - 7 Then Me.Top = (objMainForm.Top + objMainForm.Height) - Me.Height - objMainForm.sbMainStatus.Height - 7 End If '*************************************** ' Record Distance From Top/Left of MDI Parent ' This Value Is Used For When The MDI ' Parent Is Moved. MDI Parent's Move Event Also ' Moves This Form To Continue "ChildForm" Appearance '*************************************** If Not objMainForm.IsMoving Then DistanceFromMDIParentTop = Me.Top - objMainForm.Top DistanceFromMDIParentLeft = Me.Left - objMainForm.Left End If End Sub