#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <ButtonConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
#include <EditConstants.au3>
#include <ListViewConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("控件变化测试", 392, 265)
GUISetBkColor(0x000000)
$Button1 = GUICtrlCreateButton("显示图片", 8, 24, 40, 35)
$Button2 = GUICtrlCreateButton("显示图片", 8, 70, 40, 35)
$Button3 = GUICtrlCreateButton("显示编辑", 8, 115, 40, 35)
$Button4 = GUICtrlCreateButton("隐藏控件", 8, 161, 40, 35)
$Button5 = GUICtrlCreateButton("退出测试", 8, 207, 40, 35)
$Pic1 = GUICtrlCreatePic("F:\图片\2.jpg", 110, 24, 260, 220)
GUICtrlSetPos($Pic1, 110,24,260,20)
$Pic2 = GUICtrlCreatePic("F:\图片\11.jpg", 110, 24, 260, 220)
_ControlChange($Form1, $Pic2, 1, 100,5)
$Edit1 = GUICtrlCreateEdit("文本编辑框", 110, 24, 135, 217)
GUICtrlSetPos($Edit1, 110,24,1,217)
GUICtrlSetState($Pic1,$GUI_HIDE)
GUICtrlSetState($Pic2,$GUI_HIDE)
GUICtrlSetState($Edit1,$GUI_HIDE)
_GUICtrlButton_SetImageList($Button1, _Ico(165, True))
_GUICtrlButton_SetImageList($Button2, _Ico(166, True))
_GUICtrlButton_SetImageList($Button3, _Ico(134, True))
_GUICtrlButton_SetImageList($Button4, _Ico(146, True))
_GUICtrlButton_SetImageList($Button5, _Ico(217, True))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
$mous = GUIGetCursorInfo($Form1)
If $nMsg = $GUI_EVENT_CLOSE Then
Exit
ElseIf $mous[4] = $Button1 Then
_ControlChange($Form1, $Button1, 0, 30, 3, 0, 0, 1, 0)
While $mous[4] = $Button1
If GUIGetMsg() = $Button1 Then
If GUICtrlGetState($Pic2)<>96 Then
_ControlChange($Form1, $Pic2, 1, 100,5)
GUICtrlSetState($Pic2,$GUI_HIDE)
EndIf
If GUICtrlGetState($Edit1)<>96 Then
_ControlChange($Form1, $Edit1, 1, 135,5,0,0,1,0)
GUICtrlSetState($Edit1,$GUI_HIDE)
EndIf
If GUICtrlGetState($Pic1)=96 Then
GUICtrlSetState($Pic1,$GUI_SHOW)
_ControlChange($Form1, $Pic1, 0, 100,5,0,0,0)
ElseIf GUICtrlGetState($Pic1)<>96 Then
_ControlChange($Form1, $Pic1, 1, 100,5,0,0,0)
GUICtrlSetState($Pic1,$GUI_HIDE)
EndIf
EndIf
$mous = GUIGetCursorInfo($Form1)
WEnd
_ControlChange($Form1, $Button1, 1, 30, 3, 0, 0, 1, 0)
ElseIf $mous[4] = $Button2 Then
_ControlChange($Form1, $Button2, 0, 30, 3, 0, 0, 1, 0)
While $mous[4] = $Button2
If GUIGetMsg() = $Button2 Then
If GUICtrlGetState($Pic1)<>96 Then
_ControlChange($Form1, $Pic1, 1, 100,5,0,0,0)
GUICtrlSetState($Pic1,$GUI_HIDE)
EndIf
If GUICtrlGetState($Edit1)<>96 Then
_ControlChange($Form1, $Edit1, 1, 135,5,0,0,1,0)
GUICtrlSetState($Edit1,$GUI_HIDE)
EndIf
If GUICtrlGetState($Pic2)=96 Then
GUICtrlSetState($Pic2,$GUI_SHOW)
_ControlChange($Form1, $Pic2, 0, 100,5)
ElseIf GUICtrlGetState($Pic2)<>96 Then
_ControlChange($Form1, $Pic2, 1, 100,5)
GUICtrlSetState($Pic2,$GUI_HIDE)
EndIf
EndIf
$mous = GUIGetCursorInfo($Form1)
WEnd
_ControlChange($Form1, $Button2, 1, 30, 3, 0, 0, 1, 0)
ElseIf $mous[4] = $Button3 Then
_ControlChange($Form1, $Button3, 0, 30, 3, 0, 0, 1, 0)
While $mous[4] = $Button3
If GUIGetMsg() = $Button3 Then
If GUICtrlGetState($Pic1)<>96 Then
_ControlChange($Form1, $Pic1, 1, 100,5,0,0,0)
GUICtrlSetState($Pic1,$GUI_HIDE)
EndIf
If GUICtrlGetState($Pic2)<>96 Then
_ControlChange($Form1, $Pic2, 1, 100,5)
GUICtrlSetState($Pic2,$GUI_HIDE)
EndIf
If GUICtrlGetState($Edit1)=96 Then
GUICtrlSetState($Edit1,$GUI_SHOW)
_ControlChange($Form1, $Edit1, 0, 135,5,0,0,1,0)
ElseIf GUICtrlGetState($Edit1)<>96 Then
_ControlChange($Form1, $Edit1, 1, 135,5,0,0,1,0)
GUICtrlSetState($Edit1,$GUI_HIDE)
EndIf
EndIf
$mous = GUIGetCursorInfo($Form1)
WEnd
_ControlChange($Form1, $Button3, 1, 30, 3, 0, 0, 1, 0)
ElseIf $mous[4] = $Button4 Then
_ControlChange($Form1, $Button4, 0, 30, 3, 0, 0, 1, 0)
While $mous[4] = $Button4
If GUIGetMsg() = $Button4 Then
If GUICtrlGetState($Pic1)<>96 Then
GUICtrlSetState($Pic1,$GUI_HIDE)
_ControlChange($Form1, $Pic1, 1, 100,5,0,0,0)
EndIf
If GUICtrlGetState($Pic2)<>96 Then
GUICtrlSetState($Pic2,$GUI_HIDE)
_ControlChange($Form1, $Pic2, 1, 100,5)
EndIf
If GUICtrlGetState($Edit1)<>96 Then
GUICtrlSetState($Edit1,$GUI_HIDE)
_ControlChange($Form1, $Edit1, 1, 135,5,0,0,1,0)
EndIf
EndIf
$mous = GUIGetCursorInfo($Form1)
WEnd
_ControlChange($Form1, $Button4, 1, 30, 3, 0, 0, 1, 0)
ElseIf $mous[4] = $Button5 Then
_ControlChange($Form1, $Button5, 0, 30, 3, 0, 0, 1, 0)
While $mous[4] = $Button5
If GUIGetMsg() = $Button5 Then Exit
$mous = GUIGetCursorInfo($Form1)
WEnd
_ControlChange($Form1, $Button5, 1, 30, 3, 0, 0, 1, 0)
EndIf
WEnd
Func _Ico($nIconID = 0, $fLarge = False, $sFile = "shell32.dll")
Local $iSize = 16
If $fLarge Then $iSize = 32
Local $hImagetem = _GUIImageList_Create($iSize, $iSize, 5, 3)
If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
_GUIImageList_AddBitmap($hImagetem, $sFile)
Else
_GUIImageList_AddIcon($hImagetem, $sFile, $nIconID, $fLarge)
EndIf
Return $hImagetem
EndFunc ;==>_Ico
Func _ControlChange($FormID, $controlID, $iStup = 0, $iMax = 10, $iStep = 2, $iXs = 1, $iYs = 1, $iWs = 1, $iHs = 1)
;~ 控件变化动画效果
;~ _ControlChange (窗口标题/ID, 控件ID, 变化设置 0变大否则变小, 变化大小, 变化速度, X坐标变化, Y坐标变化,宽度变化,高度变化)
$iPos = ControlGetPos($FormID, "", $controlID)
$iX = $iPos[0]
$iY = $iPos[1]
$iW = $iPos[2]
$iH = $iPos[3]
If $iStup = 0 Then
$iS1 = 1
$iS2 = 1
Else
$iS1 = -1
$iS2 = -1
EndIf
Dim $iXt = $iX, $iYt = $iY, $iWt = $iW, $iHt = $iH
For $i = 1 To $iMax Step $iStep
If $iXs = 1 Then $iXt = Execute($iX - $iS1 * $i)
If $iYs = 1 Then $iYt = Execute($iY - $iS1 * $i)
If $iWs = 1 Then $iWt = Execute($iW + $iS2 * 2 * $i)
If $iHs = 1 Then $iHt = Execute($iH + $iS2 * 2 * $i)
GUICtrlSetPos($controlID, $iXt, $iYt, $iWt, $iHt)
Sleep(1)
Next
EndFunc