回复 4# wsfda
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>
Opt("GUIOnEventMode", 1)
Global Enum $idOpen = 1000, $idSave, $idInfo
Local $Button[5]
$Form1 = GUICreate("Form1", 616, 112, 192, 132)
GUISetOnEvent(-3,"_exit")
for $i=0 to 4
$Button[$i] = GUICtrlCreateButton("Button"&$i+1, 16+($i*120), 8, 105, 97)
GUICtrlSetOnEvent(-1,"Button_Click")
Next
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")
While 1
Sleep(100)
WEnd
Func _exit()
Exit
EndFunc
Func Button_Click()
msgbox(0,0,"Clicked Button"&@GUI_CtrlId-3+1)
EndFunc
Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam)
$aa=GUIGetCursorInfo($hWnd)
If $aa[4]<=3 then
Local $hMenu
$hMenu = _GUICtrlMenu_CreatePopup ()
_GUICtrlMenu_InsertMenuItem ($hMenu, 0, "关于", $idOpen)
_GUICtrlMenu_InsertMenuItem ($hMenu, 1, "设置", $idSave)
_GUICtrlMenu_InsertMenuItem ($hMenu, 3, "", 0)
_GUICtrlMenu_InsertMenuItem ($hMenu, 3, "退出", $idInfo)
Switch _GUICtrlMenu_TrackPopupMenu ($hMenu, $iwParam,-1,-1,1,1,2)
Case $idOpen
about()
Case $idSave
setup()
Case $idInfo
exit
EndSwitch
_GUICtrlMenu_DestroyMenu ($hMenu)
Return True
Else
Local $hMenu
$hMenu = _GUICtrlMenu_CreatePopup ()
_GUICtrlMenu_InsertMenuItem ($hMenu, 0, "删除快捷方式", $idOpen)
_GUICtrlMenu_InsertMenuItem ($hMenu, 1, "", 0)
_GUICtrlMenu_InsertMenuItem ($hMenu, 2, "打开文件位置", $idSave)
Switch _GUICtrlMenu_TrackPopupMenu ($hMenu, $iwParam,-1,-1,1,1,2)
Case $idOpen
delete($aa[4])
case $idSave
;~ $pathfile=IniRead("quick.ini","工具",$aa[4]-3,"error")
;~ if $pathfile<>"error" Then
;~ $shell=iniread("quick.ini",$pathfile,1,"")
;~ Run('explorer /select, "' & $shell & '"')
;~ EndIf
EndSwitch
_GUICtrlMenu_DestroyMenu ($hMenu)
Return True
EndIf
EndFunc ;==>WM_CONTEXTMENU
Func about()
msgbox(0,0,"ABout")
EndFunc
Func setup()
msgbox(0,0,"setup")
EndFunc
Func delete($C_id)
GUICtrlDelete($C_id)
EndFunc
|