一、通用GUI通知
使用通用GUI通知需要注册WM_NOTIFY消息,下面是全部的通用GUI通知的值及介绍:
Global Const $WM_NOTIFY = 0x004E ; //这是使用通用GUI通知时需要用到的消息ID
Global Const $NM_FIRST = 0 ; //无具体含义,只是方便赋值而已
Global Const $NM_LAST = (-99) ; //同上
Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1) ; //内存不足
Global Const $NM_CLICK = ($NM_FIRST - 2) ; //单击
Global Const $NM_DBLCLK = ($NM_FIRST - 3) ; //双击
Global Const $NM_RETURN = ($NM_FIRST - 4) ; //用户在输入框按下了ENTER键
Global Const $NM_RCLICK = ($NM_FIRST - 5) ; //右键单击
Global Const $NM_RDBLCLK = ($NM_FIRST - 6) ; //右键双击
Global Const $NM_SETFOCUS = ($NM_FIRST - 7) ; //获取焦点
Global Const $NM_KILLFOCUS = ($NM_FIRST - 8) ; //失去焦点
Global Const $NM_HOVER = ($NM_FIRST - 13) ; //鼠标移动到控件上
Global Const $NM_KEYDOWN = ($NM_FIRST - 15) ; //用户按键
Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16) ; //子控件被鼠标按住拖动到适当位置以后鼠标释放时子控件向父控件产发送的消息
Global Const $NM_SETCURSOR = ($NM_FIRST - 17) ; //鼠标样式改变
Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19) ; //控件创建了一个工具栏提示
Global Const $NM_THEMECHANGED = ($NM_FIRST-22) ; //系统主题变化
Global Const $NM_RDOWN = ($NM_FIRST - 21) ; //按下右键(不要求按在控件上)
Global Const $NM_LDOWN = ($NM_FIRST - 20) ; //按下左键(不要求按在控件上)
一个例子:
CODE: AutoIt#Include <GuiListView.au3>
$Form1 = GUICreate("AForm1", 452, 199, 177, 118)
$ListView1 = GUICtrlCreateListView("1|2|3", 10, 10, 431, 156)
$ListView1_0 = GUICtrlCreateListViewItem("1", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("item2", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("item3", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("item4", $ListView1)
$ListView1_4 = GUICtrlCreateListViewItem("item5", $ListView1)
$dd = GUICtrlCreateInput("",10,179)
Global Const $WM_NOTIFY = 0x004E
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
GuiSetState()
Do
Until GUIGetMsg()=-3
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
Const $NM_FIRST = 0
Const $NM_CLICK = ($NM_FIRST - 2)
Const $NM_HOVER = ($NM_FIRST - 13)
#forceref $hWndGUI, $MsgID, $wParam
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
If @error Then Return
$event = DllStructGetData($tagNMHDR, 3)
If $event = $NM_CLICK Then
GUICtrlSetData($dd,"鼠标选中:"&_GUICtrlListViewGetItemText($ListView1, _GUICtrlListViewGetSelectedIndices($ListView1)))
EndIf
$tagNMHDR = 0
$event = 0
$lParam = 0
EndFunc
二、控件专用通知
你可以在http://msdn.microsoft.com/librar ... tls/wincontrols.asp 里找到一份控件列表,通过这个列表你可以找到每个控件的介绍页面,比如按钮控件的页面就是http://msdn.microsoft.com/librar ... buttons/buttons.asp。
在每个控件的页面下都有专门的Notifications项,用以介绍不同的控件通知。因为这类通知实在太多,我仅以Edit控件为例作一下介绍,其他控件的通知可以以此类推。
Edit控件的详细信息可以在http://msdn.microsoft.com/librar ... ls/editcontrols.asp 找到,下面是Edit控件所有通知的值和说明:
Global Const $EN_ALIGN_LTR_EC = 0x700 ; //文本排列顺序更变为从左到右
Global Const $EN_ALIGN_RTL_EC = 0x701; //文本排列顺序更变为从右到左
Global Const $EN_CHANGE = 0x300 ; //文本发生改变
Global Const $EN_ERRSPACE = 0x500 ; //内存不足
Global Const $EN_HSCROLL = 0x601 ; //用户点击横向滚动条
Global Const $EN_KILLFOCUS = 0x200 ; //失去焦点
Global Const $EN_MAXTEXT = 0x501 ; //文本已满
Global Const $EN_SETFOCUS = 0x100 ; //获取焦点
Global Const $EN_UPDATE = 0x400 ; //控件重绘
Global Const $EN_VSCROLL = 0x602 ; //用户点击纵向滚动条
一个例子:
CODE:
AutoItGuiCreate("MyGUI", 392, 66)
$Input_1 = GuiCtrlCreateInput("", 10, 20, 190, 30)
$Label_2 = GuiCtrlCreateLabel("", 220, 30, 130, 20)
Global Const $WM_COMMAND = 0x0111
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = -3
ExitLoop
Case Else
;;;
EndSelect
WEnd
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local Const $EN_CHANGE = 0x300
Local $nNotifyCode = BitShift($wParam,16)
Local $nID = BitAND($wParam,0xFFFF)
Local $hCtrl = $lParam
If $nNotifyCode = $EN_CHANGE Then GUICtrlSetData($Label_2,GUICtrlRead($Input_1))
EndFunc ;==>MY_WM_COMMAND |