编辑框的右键菜单问题
本帖最后由 gto250 于 2009-6-23 21:40 编辑任何才能在编辑框上使用自定右键菜单。看帮助上说好像编辑框的右键菜单是不可更改的,谁有思路吗? 这个不难吧#include <GuiConstants.au3>
$Gui = GUICreate("test")
$Edit = GUICtrlCreateEdit("", 20, 20)
$DummyMenu = GUICtrlCreateDummy()
$ContextMenu = GUICtrlCreateContextMenu($DummyMenu)
$MenuItem1 = GUICtrlCreateMenuItem("菜单1", $ContextMenu)
$MenuItem2 = GUICtrlCreateMenuItem("菜单2", $ContextMenu)
GUICtrlCreateMenuItem("", $ContextMenu)
$ExitMenuItem = GUICtrlCreateMenuItem("退出", $ContextMenu)
GUISetState()
While 1
$CurInfo = GUIGetCursorInfo($Gui)
$Msg = GUIGetMsg()
Select
Case $Msg = -3
Exit
Case $CurInfo = 1 And $CurInfo = $Edit
ShowMenu($Gui, $ContextMenu)
EndSelect
WEnd
; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $nContextID)
Local $hMenu = GUICtrlGetHandle($nContextID)
$arPos = MouseGetPos()
Local $x = $arPos
Local $y = $arPos
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc
要右键双击才能弹出自定义的菜单 单击就能成功!
正所谓难者不会,会者不难
谢谢了 先收藏, 慢慢研读之,谢谢 高,我还远远不够 怎么样开始学呀 又学到一点东西,但还要多花点时间去消化 谢谢楼主,学习学习! 关键的问题是获取右键菜单的句柄,这个问题好像没有解决 反过来,怎么自动对右键菜单操作?
页:
[1]