本帖最后由 雪栀 于 2011-8-28 13:12 编辑
解决方案:采用powerofos提供的UDF(见6楼),这是网络收音机的部分源码,完整源码等整理好了发布在源码区,谢谢大家的帮助,先上个图吧!
这个是创建三个图标按钮,像这样:GUICtrlCreateButton("按钮", 0, 0, 10, 6, $BS_ICON),然后鼠标在其上面时换为带有发光效果的ico,结果发现只有写在前面检测的那个按钮有此效果,问题貌似不太好表达,看代码以及里面的注释会清楚一些,ico和au3都已经压缩上传,下面是代码(与压缩包中一致)#NoTrayIcon
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#region GUI
$Form = GUICreate("ICO Button Test", 200, 200, 200, 200)
$Play = GUICtrlCreateButton("play", 8, 60, 32, 30, $BS_ICON)
GUICtrlSetImage(-1, "skin\play_1.ico", 0)
$Record = GUICtrlCreateButton("rec", 48, 60, 32, 30, $BS_ICON)
GUICtrlSetImage(-1, "skin\rec_1.ico", 0)
$Add = GUICtrlCreateButton("opt", 88, 60, 32, 30, $BS_ICON)
GUICtrlSetImage(-1, "skin\opt_1.ico", 0)
GUISetState(@SW_SHOW)
#endregion GUI
While 1
Local $msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Play
If GUICtrlRead($Play) = "play" Then
GUICtrlSetData($Play, "stop")
GUICtrlSetImage($Play, "skin\stop_2.ico",0)
Else
If GUICtrlRead($Record) = "save" Then
MsgBox(0, "注意", "您正在录音!")
ElseIf GUICtrlRead($Record) = "rec" Then
GUICtrlSetData($Play, "play")
GUICtrlSetImage($Play, "skin\play_2.ico",0)
EndIf
EndIf
Case $msg = $Record
Select
Case GUICtrlRead($Record) = "rec"
GUICtrlSetData($Record, "save")
GUICtrlSetImage($Record, "skin\save_2.ico",0)
;此处加入相关代码
Case GUICtrlRead($Record) = "save"
GUICtrlSetData($Record, "rec")
GUICtrlSetImage($Record, "skin\rec_2.ico",0)
;此处加入相关代码
EndSelect
;电台管理
Case $msg = $Add
;此处加入相关代码
EndSelect
;===========
$Pos = GUIGetCursorInfo($Form)
Dim $Last
;下面是方法一,不行的原因好像是反应不过来,ico和按钮都不对应了
;If $Last <> $Pos[4] Then
; If $Pos[4] = $play Or $Pos[4] = $record Or $Pos[4] = $Add Then GUICtrlSetImage($pos[4], "skin" & GUICtrlRead($Pos[4]) & "_2.ico", 0)
; If $Last = $play Or $Last = $record Or $Last = $Add Then GUICtrlSetImage($Last, "skin" & GUICtrlRead($Pos[4]) & "_1.ico", 0)
;EndIf
;下面是方法二,不行的原因是当鼠标移至$Record上时,同样满足$Pos[4] <> $Play,所以执行了GUICtrlSetImage($Play, "skin" & GUICtrlRead($Play) & "_1.ico", 0)
;而非GUICtrlSetImage($Record, "skin" & GUICtrlRead($Record) & "_2.ico", 0)
;现在要求鼠标移至某一按钮上时,对应改变到有发光效果的ico
Select
Case $Pos[4] = $Play
GUICtrlSetImage($Play, "skin" & GUICtrlRead($Play) & "_2.ico", 0)
Case $Pos[4] <> $Play
GUICtrlSetImage($Play, "skin" & GUICtrlRead($Play) & "_1.ico", 0)
Case $Pos[4] = $Record
GUICtrlSetImage($Record, "skin" & GUICtrlRead($Record) & "_2.ico", 0)
Case $Pos[4] <> $Record
GUICtrlSetImage($Record, "skin" & GUICtrlRead($Record) & "_1.ico", 0)
Case $Pos[4] = $Add
GUICtrlSetImage($Record, "skin\opt_2.ico",0)
Case $Pos[4] <> $Add
GUICtrlSetImage($Record, "skin\opt_1.ico",0)
EndSelect
$Last = $Pos[4]
WEnd
|