[已解决]GUIGetCursorInfo()有关问题,已知原因不知怎么解决
本帖最后由 雪栀 于 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 Then
; If $Pos = $play Or $Pos = $record Or $Pos = $Add Then GUICtrlSetImage($pos, "skin\" & GUICtrlRead($Pos) & "_2.ico", 0)
; If $Last = $play Or $Last = $record Or $Last = $Add Then GUICtrlSetImage($Last, "skin\" & GUICtrlRead($Pos) & "_1.ico", 0)
;EndIf
;下面是方法二,不行的原因是当鼠标移至$Record上时,同样满足$Pos <> $Play,所以执行了GUICtrlSetImage($Play, "skin\" & GUICtrlRead($Play) & "_1.ico", 0)
;而非GUICtrlSetImage($Record, "skin\" & GUICtrlRead($Record) & "_2.ico", 0)
;现在要求鼠标移至某一按钮上时,对应改变到有发光效果的ico
Select
Case $Pos = $Play
GUICtrlSetImage($Play, "skin\" & GUICtrlRead($Play) & "_2.ico", 0)
Case $Pos <> $Play
GUICtrlSetImage($Play, "skin\" & GUICtrlRead($Play) & "_1.ico", 0)
Case $Pos = $Record
GUICtrlSetImage($Record, "skin\" & GUICtrlRead($Record) & "_2.ico", 0)
Case $Pos <> $Record
GUICtrlSetImage($Record, "skin\" & GUICtrlRead($Record) & "_1.ico", 0)
Case $Pos = $Add
GUICtrlSetImage($Record, "skin\opt_2.ico",0)
Case $Pos <> $Add
GUICtrlSetImage($Record, "skin\opt_1.ico",0)
EndSelect
$Last = $Pos
WEnd 肿么了……为什么还没有人回答呢?我表达得不清晰?还是我没发现这个问题很简单,没人想回答? 不推荐用这种方式,太占资源,发应缓慢
论坛搜索下WM_MOUSEMOVE等可以找到类似的代码. 索性使用官网的 onhover reigister UDF... 回复 4# powerofos
请问在哪里找得到这个UDF,官方论坛搜了之后是No Results Found…… 回复 5# 雪栀
本帖最后由 雪栀 于 2011-8-28 10:37 编辑
回复 6# powerofos
很不错的UDF,简单看了,但现在没时间试,晚上试一下,谢谢了
我是即将上高二的学生,主要是今天学校网上选择选修科目,还要再咨询下老师。 {:face (239):}好用,不卡,感谢分享。
页:
[1]