|
#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[3] = 1 And $CurInfo[4] = $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[0]
Local $y = $arPos[1]
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|