本帖最后由 ccxw1983 于 2010-2-7 11:42 编辑
使用
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
的过程中发现一个问题,当执行了
GUICtrlSetStyle($Label, $SS_CENTER)
后,注册的消息不再有用了
代码如下,请高手指点;GUIRegisterMsg + GUICtrlSetStyle = bug ?
#include <Date.au3>
#include <Constants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1); GUI OnEvent
Global Const $STN_DBLCLK = 1
Local $win_main = GUICreate("", 450, 30, 450, 30)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui_win_tool")
Local $Label = GUICtrlCreateLabel("", 0, 0, 450, 30)
;GUICtrlSetOnEvent($Label, "gui_win_tool")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState(@SW_SHOW)
Local $begin_ticks = _Date_Time_GetTickCount()
Local $waitticks = 9000 / 1
While 1
If _Date_Time_GetTickCount() - $begin_ticks > $waitticks Then
GUICtrlSetStyle($Label, $SS_CENTER)
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUICtrlSetData($Label, "double click me can not show TrayTip now! ")
Else
GUICtrlSetData($Label, "double click me to show TrayTip. " & @CRLF _
& "after " & Int(($waitticks - _Date_Time_GetTickCount() + $begin_ticks) / 1000) _
& " seconds, this will not work,is this a bug for GUIRegisterMsg?")
EndIf
Sleep(100)
WEnd
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
;ConsoleWrite("$hWnd=" & $hWnd & @CRLF)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0xFFFF)
Local $hCtrl = $lParam
Switch $nID
Case $Label
Switch $nNotifyCode
Case $STN_DBLCLK
TrayTip("", "dbclick at " & @HOUR & ":" & @MIN & ":" & @SEC, 1, 1)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_COMMAND
Func gui_win_tool()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
;Case $Label
; TrayTip("", " some click at " & @HOUR & ":" & @MIN & ":" & @SEC, 1, 1)
EndSwitch
EndFunc ;==>gui_win_tool
|