#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>
Dim $swap = False,$bstatus = ""
#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("E:\image\美女足球\01.jpg", 110, 24, 260, 220)
GUICtrlSetPos($Pic1, 110,24,260,20)
$Pic2 = GUICtrlCreatePic("E:\image\美女足球\02.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
While $mous[4] = $Button1
If GUIGetMsg() = $Button1 Then
If $bstatus <> "b1" Then $swap = Not $swap
If Not $swap Then
_ControlReset ()
Else
If $bstatus <> "b1" Then _ControlReset ()
_ControlChange($Form1, $Button1, 0, 30, 3, 0, 0, 1, 0)
$bstatus = "b1"
EndIf
$swap = Not $swap
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
ElseIf $mous[4] = $Button2 Then
While $mous[4] = $Button2
If GUIGetMsg() = $Button2 Then
If $bstatus <> "b2" Then $swap = Not $swap
If Not $swap Then
_ControlReset ()
Else
If $bstatus <> "b2" Then _ControlReset ()
_ControlChange($Form1, $Button2, 0, 30, 3, 0, 0, 1, 0)
$bstatus = "b2"
EndIf
$swap = Not $swap
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
ElseIf $mous[4] = $Button3 Then
While $mous[4] = $Button3
If GUIGetMsg() = $Button3 Then
If $bstatus <> "b3" Then $swap = Not $swap
If Not $swap Then
_ControlReset ()
Else
If $bstatus <> "b3" Then _ControlReset ()
_ControlChange($Form1, $Button3, 0, 30, 3, 0, 0, 1, 0)
$bstatus = "b3"
EndIf
$swap = Not $swap
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
ElseIf $mous[4] = $Button4 Then
While $mous[4] = $Button4
If GUIGetMsg() = $Button4 Then
If $bstatus <> "b4" Then $swap = Not $swap
If Not $swap Then
_ControlReset ()
Else
If $bstatus <> "b4" Then _ControlReset ()
_ControlChange($Form1, $Button4, 0, 30, 3, 0, 0, 1, 0)
$bstatus = "b4"
EndIf
$swap = Not $swap
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
ElseIf $mous[4] = $Button5 Then
While $mous[4] = $Button5
If GUIGetMsg() = $Button5 Then
If $bstatus <> "b5" Then $swap = Not $swap
If Not $swap Then
_ControlReset ()
Else
If $bstatus <> "b5" Then _ControlReset ()
_ControlChange($Form1, $Button5, 0, 30, 3, 0, 0, 1, 0)
$bstatus = "b5"
EndIf
$swap = Not $swap
Exit
EndIf
$mous = GUIGetCursorInfo($Form1)
WEnd
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 ;==>_ControlChange
Func _ControlReset ()
GUICtrlSetPos($Button1,8,24,40,35)
GUICtrlSetPos($Button2,8,70,40,35)
GUICtrlSetPos($Button3,8,115,40,35)
GUICtrlSetPos($Button4,8,161,40,35)
GUICtrlSetPos($Button5,8,207,40,35)
EndFunc