本帖最后由 afan 于 2018-9-28 16:37 编辑
注意: 示例 ini 文件如果用ini内置函数操作,不要用 UTF-8 格式保存,那样会乱码。本例已存为 ANSI
#include <GuiMenu.au3>
Global $hGUI
Example()
Func Example()
; 创建 GUI
$hGUI = GUICreate('test')
GUISetState(@SW_SHOW)
GUICtrlCreateLabel('点击选择 >', 10, 10, 300, 20)
While 1
Switch GUIGetMsg()
Case -3
Exit
Case 3
_CreateMenu()
EndSwitch
WEnd
EndFunc ;==>Example
Func _CreateMenu()
Local $fIni = 'set.ini'
Local $aIni = IniReadSection($fIni, 'one')
If @error Then Return SetError(1, 0, 0)
Local $hMenu = _GUICtrlMenu_CreatePopup()
Local Enum $itemC0 = 1500
Local $aIni1, $hMenuC
For $ii = 1 To $aIni[0][0]
$aIni1 = IniReadSection($fIni, $aIni[$ii][1])
If @error Then ContinueLoop
$hMenuC = _GUICtrlMenu_CreateMenu()
For $jj = 1 To $aIni1[0][0]
_GUICtrlMenu_AddMenuItem($hMenuC, $aIni1[$jj][1], $itemC0)
Next
_GUICtrlMenu_AddMenuItem($hMenu, $aIni[$ii][1], 0, $hMenuC)
Next
_GUICtrlMenu_TrackPopupMenu($hMenu, $hGUI)
_GUICtrlMenu_DestroyMenu($hMenu)
EndFunc ;==>_CreateMenu
|