Global $iSpacingY = 40
Global $ini = @ScriptDir & '\123.ini'
Global $Form1 = GUICreate('控件上下移动', 500, 340)
Global $aILabel1 = _Label_Lst()
Local $ILabel = _Label_DU()
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $ILabel - 9 To $ILabel
$iX = ($nMsg - 13) / 2 + 1
If IsInt($iX) Then
_Move($iX, 'down')
Else
_Move(Floor($iX), 'up')
EndIf
EndSwitch
WEnd
Func _Label_Lst()
Local $Label[6]
For $ii = 1 To UBound($Label) - 1
GUICtrlCreateLabel(StringFormat('%02s.', $ii), 30, $iSpacingY * $ii + 20, 15, 20, 0x200)
GUICtrlSetColor(-1, 0x6622DD)
$Label[$ii] = GUICtrlCreateLabel(IniRead($ini, $ii, 'Name', ''), 50, $iSpacingY * $ii + 20, 160, 20, 0x200)
Next
Return $Label
EndFunc ;==>_Label_Lst
Func _Label_DU()
Local $id
For $ii = 1 To 5
GUICtrlCreateLabel('↓', 400, $iSpacingY * $ii + 20, 20, 20, 0x200)
GUICtrlSetBkColor(-1, 0xfce6c9)
$id = GUICtrlCreateLabel('↑', 422, $iSpacingY * $ii + 20, 20, 20, 0x200)
GUICtrlSetBkColor(-1, 0xfce6c9)
Next
GUICtrlSetState($id - 1, 128)
GUICtrlSetState($id - 8, 128)
Return $id
EndFunc ;==>_Label_DU
Func _Move($iX, $sdirection)
Local $aCP = ControlGetPos($Form1, '', $aILabel1[$iX])
If $sdirection = 'down' Then
Local $iX1 = $iX + 1
Else
Local $iX1 = $iX - 1
EndIf
Local $aCP1 = ControlGetPos($Form1, '', $aILabel1[$iX1])
GUICtrlSetPos($aILabel1[$iX], $aCP1[0], $aCP1[1])
GUICtrlSetPos($aILabel1[$iX1], $aCP[0], $aCP[1])
Local $iTmp = $aILabel1[$iX]
$aILabel1[$iX] = $aILabel1[$iX1]
$aILabel1[$iX1] = $iTmp
EndFunc ;==>_Move