还是关于WM_NOTIFY响应下拉菜单事件[已解决]
本帖最后由 xyhqqaa 于 2021-1-27 08:17 编辑关于WM_NOTIFY还是蒙蒙~~~两种写法,写法二却没有达到效果。特来请教论坛的大佬们帮忙看看
写法一,示例来自帮助文件,可以正常弹出下拉菜单
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $ilParam)
#forceref $hWnd, $iMsg, $wParam
Local $tNMTOOLBAR = DllStructCreate($tagNMTOOLBAR, $ilParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMTOOLBAR, "hWndFrom"))
Local $iItem = DllStructGetData($tNMTOOLBAR, "iItem")
Local $iIDFrom = DllStructGetData($tNMTOOLBAR, "IDFrom")
Local $iCode = DllStructGetData($tNMTOOLBAR, "Code")
local $iIndex = DllStructGetData($tNMTOOLBAR, "Index")
Switch $hWndFrom
Case $hToolbar
Switch $iCode
Case $TBN_DROPDOWN
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "Template 1", 2000)
_GUICtrlMenu_AddMenuItem($hMenu, "Template 2", 2001)
_GUICtrlMenu_AddMenuItem($hMenu, "Template 3", 2002)
_GUICtrlMenu_TrackPopupMenu($hMenu, $g_hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
写法二,改写成这样的话,为啥无法响应下拉菜单事件,对WM_NOTIFY事件还是一知半解,特来请教,大佬如有时间,简单告知下
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMTOOLBAR = DllStructCreate($tagNMTOOLBAR, $ilParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMTOOLBAR, "hWndFrom"))
Local $iItem = DllStructGetData($tNMTOOLBAR, "iItem")
Local $iIDFrom = DllStructGetData($tNMTOOLBAR, "IDFrom")
Local $iCode = DllStructGetData($tNMTOOLBAR, "Code")
local $iIndex = DllStructGetData($tNMTOOLBAR, "Index")
Switch $hWndFrom
Case $g_hGUI ;主界面
tool_DROPDOWN_NOTIFY($hWnd, $iIDFrom, $iCode, $ilParam)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func tool_DROPDOWN_NOTIFY($hWnd, $iControl, $iMsg, $ilParam)
Switch $iControl;这两句删除的响应,但是不删除的话,是哪里冲突导致的吗
Case $hToolbar;这两句删除可以响应
Switch $iMsg
Case $TBN_DROPDOWN
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "Template 1", 2000)
_GUICtrlMenu_AddMenuItem($hMenu, "Template 2", 2001)
_GUICtrlMenu_AddMenuItem($hMenu, "Template 3", 2002)
_GUICtrlMenu_TrackPopupMenu($hMenu, $g_hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndSwitch
EndSwitch
EndFunc ;==>tool_ipmanagerEvent_NOTIFY
传参错误吧,试试
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMTOOLBAR = DllStructCreate($tagNMTOOLBAR, $ilParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMTOOLBAR, "hWndFrom"))
Local $iItem = DllStructGetData($tNMTOOLBAR, "iItem")
Local $iIDFrom = DllStructGetData($tNMTOOLBAR, "IDFrom")
Local $iCode = DllStructGetData($tNMTOOLBAR, "Code")
Local $iIndex = DllStructGetData($tNMTOOLBAR, "Index")
Switch $hWnd
Case $g_hGUI ;主界面
tool_DROPDOWN_NOTIFY($hWndFrom, $iCode)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func tool_DROPDOWN_NOTIFY($hWndFrom, $iCode)
Switch $hWndFrom;这两句删除的响应,但是不删除的话,是哪里冲突导致的吗
Case $hToolbar;这两句删除可以响应
Switch $iCode
Case $TBN_DROPDOWN
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "Template 1", 2000)
_GUICtrlMenu_AddMenuItem($hMenu, "Template 2", 2001)
_GUICtrlMenu_AddMenuItem($hMenu, "Template 3", 2002)
_GUICtrlMenu_TrackPopupMenu($hMenu, $g_hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndSwitch
EndSwitch
EndFunc ;==>tool_DROPDOWN_NOTIFY afan 发表于 2021-1-26 23:35
传参错误吧,试试
原来还可以这么写,谢谢A大。这么晚了,您早点休息呀 xyhqqaa 发表于 2021-1-27 00:21
原来还可以这么写,谢谢A大。这么晚了,您早点休息呀
不客气~
页:
[1]