I haven't provided any code for a while for DropIt, so here you are...
Code:
Func _GUIInBounds($hHandle) ; Original idea by wraithdu, Modified by guinness.
Local $iXPos = 5, $iYPos = 5, $tWorkArea = DllStructCreate($tagRECT)
_WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, DllStructGetPtr($tWorkArea))
Local $iLeft = DllStructGetData($tWorkArea, "Left"), $iTop = DllStructGetData($tWorkArea, "Top")
Local $iWidth = DllStructGetData($tWorkArea, "Right") - $iLeft
If _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN) > $iWidth Then
$iWidth = _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN)
EndIf
$iWidth -= $iLeft
Local $iHeight = DllStructGetData($tWorkArea, "Bottom") - $iTop
Local $aWinGetPos = WinGetPos($hHandle)
If @error Then
Return SetError(1, 0, WinMove($hHandle, "", $iXPos, $iYPos))
EndIf
If $aWinGetPos[0] < $iLeft Then
$iXPos = $iLeft
ElseIf ($aWinGetPos[0] + $aWinGetPos[2]) > $iWidth Then
$iXPos = $iWidth - $aWinGetPos[2]
Else
$iXPos = $aWinGetPos[0]
EndIF
If $aWinGetPos[1] < $iTop Then
$iYPos = $iTop
ElseIf ($aWinGetPos[1] + $aWinGetPos[3]) > $iHeight Then
$iYPos = $iHeight - $aWinGetPos[3]
Else
$iYPos = $aWinGetPos[1]
EndIf
Return WinMove($hHandle, "", $iXPos, $iYPos)
EndFunc ;==>_GUIInBounds