[己解决]两个WM_NOTIFY如何使用
本帖最后由 chzj589 于 2014-12-24 21:57 编辑两个WM_NOTIFY,一个是工具栏的,一个是ListView,为何点击ListView的WM_NOTIFYA后,工具栏的WM_NOTIFY就不能使用??
工具条栏
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $iCode, $hMenu
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$iCode = DllStructGetData($tNMHDR, "Code")
If $iCode = $TBN_DROPDOWN Then ;
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "菜单项目1", 2000)
_GUICtrlMenu_AddMenuItem($hMenu, "菜单项目2", 2001)
_GUICtrlMenu_AddMenuItem($hMenu, "菜单项目3", 2002)
_GUICtrlMenu_AddMenuItem($hMenu, "", 0)
_GUICtrlMenu_AddMenuItem($hMenu, "菜单项目4", 2003)
_GUICtrlMenu_AddMenuItem($hMenu, "菜单5", 2004)
_GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
ListView
Func _WM_NOTIFYA($hWnd, $iMsg, $iwParam, $ilParam)
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($PListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
If $iIndex >= 0 Then _binzzdup()
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_NOTIFYAA
解决方法看二楼
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $iCode, $hMenu
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView;这里改成你的listview的ID
Switch $iCode
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
If $iIndex >= 0 Then _binzzdup()
EndSwitch
Case $hToolbar;这个是你的toolbar的ID
Switch $iCode
Case $TBN_DROPDOWN
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "菜单项目1", 2000)
_GUICtrlMenu_AddMenuItem($hMenu, "菜单项目2", 2001)
_GUICtrlMenu_AddMenuItem($hMenu, "菜单项目3", 2002)
_GUICtrlMenu_AddMenuItem($hMenu, "", 0)
_GUICtrlMenu_AddMenuItem($hMenu, "菜单项目4", 2003)
_GUICtrlMenu_AddMenuItem($hMenu, "菜单5", 2004)
_GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_NOTIFY 回复 2# seniors
谢谢!我调试一下! 学习了 谢谢 ! 回复 2# seniors
谢谢!调试成功! 调试成功的效果图
新手路过 进来学习下 学习了,这个不错,case 回复 2# seniors
如果兄台能细细讲下 _WM_NOTIFY 函数里 传人的及定义的各个变量、引用的各个方法 的意义再好不过 回复 9# vigiles
这个要讲解又可以写一本书了
因为这是winapi函数接口的硬性规定,win内部也是这样操作的。
是先有了规定,再有对应的函数开发的
页:
[1]