#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ModernMenuRaw.au3>

Local $sStatus = "Готово", $iFileMenu, $iOpenFile, $iStatusLabel
Local $iHelpMenu, $iInfoItem, $iExit, $iRecentFilesMenu, $hGui
Local $iViewMenu, $iViewStatusItem, $iStyleitem, $iCancel

$hGui = GUICreate("Элемент меню в GUI", 300, 200)

$iFileMenu = GUICtrlCreateMenu("&Файл")
$iOpenFile = _GUICtrlCreateODMenuItem("Открыть", $iFileMenu, "shell32.dll", -4)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$iHelpMenu = GUICtrlCreateMenu("?")
_GUICtrlCreateODMenuItem("Сохранить", $iFileMenu, "shell32.dll", -6)
GUICtrlSetState(-1, $GUI_DISABLE)
_GUICtrlCreateODMenuItem("", $iFileMenu, 2) ; создаёт разделительную линию
$iInfoItem = _GUICtrlCreateODMenuItem("Информация", $iHelpMenu, "shell32.dll", -222)
$iRecentFilesMenu = _GUICtrlCreateODMenu("Последние файлы", $iFileMenu, "shell32.dll", -222)
$iExit = _GUICtrlCreateODMenuItem("Выход", $iFileMenu, "shell32.dll", -28)

$iViewMenu = GUICtrlCreateMenu("Вид", -1, 1) ; Создан до элемента меню "?"
$iViewStatusItem = _GUICtrlCreateODMenuItem("Строка состояния", $iViewMenu)
GUICtrlSetState(-1, $GUI_CHECKED)
$iStyleitem = _GUICtrlCreateODMenuItem("Стиль GUI POPUP", $iViewMenu)
_GUICtrlCreateODMenuItem("", $iViewMenu)
$iMRadio1 = _GUICtrlCreateODMenuItem("Радио1", $iViewMenu, "", 0, 1)
$iMRadio2 = _GUICtrlCreateODMenuItem("Радио2", $iViewMenu, "", 0, 1)
$iMRadio3 = _GUICtrlCreateODMenuItem("Радио3", $iViewMenu, "", 0, 1)
GUICtrlSetState(-1, $GUI_CHECKED)
$iMRadio4 = _GUICtrlCreateODMenuItem("Радио4", $iViewMenu, "", 0, 1)


$iButton = GUICtrlCreateButton("OK", 50, 130, 70, 20)
GUICtrlSetState(-1, $GUI_FOCUS)
$iCancel = GUICtrlCreateButton("Отмена", 180, 130, 70, 20)

$i_CM_Btn = GUICtrlCreateContextMenu($iButton)
$i_CM_BtnItem = _GUICtrlCreateODMenuItem("О кнопке", $i_CM_Btn, "shell32.dll", -222)

$iContMenu = GUICtrlCreateContextMenu()

$i_CM_newsubmenu = _GUICtrlCreateODMenu("Новое", $iContMenu, "shell32.dll", -5)
$i_CM_textitem = _GUICtrlCreateODMenuItem("Текст", $i_CM_newsubmenu, "shell32.dll", -71)

$i_CM_OpenFile = _GUICtrlCreateODMenuItem("Открыть", $iContMenu, "shell32.dll", -4)
$i_CM_SaveFile = _GUICtrlCreateODMenuItem("Сохранить", $iContMenu, "shell32.dll", -6)
_GUICtrlCreateODMenuItem("", $iContMenu) ; разделитель

$i_CM_infoitem = _GUICtrlCreateODMenuItem("Информация", $iContMenu, "shell32.dll", -222)


$iStatusLabel = GUICtrlCreateLabel($sStatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))

GUISetState()
While 1
	$msg = GUIGetMsg()
	Switch $msg
		Case $iMRadio1, $iMRadio2, $iMRadio3, $iMRadio4
			SetCheckedItem($msg)
		Case $iOpenFile, $i_CM_OpenFile
			$sFilePath = FileOpenDialog("Выберите файл...", @TempDir, "Все (*.*)")
			If @error <> 1 Then _GUICtrlCreateODMenuItem($sFilePath, $iRecentFilesMenu)
		Case $iViewStatusItem
			If BitAND(GUICtrlRead($iViewStatusItem), $GUI_CHECKED) = $GUI_CHECKED Then
				GUICtrlSetState($iViewStatusItem, $GUI_UNCHECKED)
				GUICtrlSetState($iStatusLabel, $GUI_HIDE)
			Else
				GUICtrlSetState($iViewStatusItem, $GUI_CHECKED)
				GUICtrlSetState($iStatusLabel, $GUI_SHOW)
			EndIf
		Case $iStyleitem
			If BitAND(GUICtrlRead($iStyleitem), $GUI_CHECKED) = $GUI_CHECKED Then
				GUICtrlSetState($iStyleitem, $GUI_UNCHECKED)
				GUISetStyle($GUI_SS_DEFAULT_GUI)
			Else
				GUICtrlSetState($iStyleitem, $GUI_CHECKED)
				GUISetStyle(BitOR($WS_BORDER, $WS_POPUP, $WS_SYSMENU))
			EndIf
		Case $iInfoItem, $i_CM_infoitem
			MsgBox(64, "Информация", "Пример с иконками", 0, $hGui)
		Case $GUI_EVENT_CLOSE, $iCancel, $iExit
			ExitLoop
	EndSwitch
WEnd
GUIDelete()

Func SetCheckedItem($DefaultItem)
	GUICtrlSetState($iMRadio1, $GUI_UNCHECKED)
	GUICtrlSetState($iMRadio2, $GUI_UNCHECKED)
	GUICtrlSetState($iMRadio3, $GUI_UNCHECKED)
	GUICtrlSetState($iMRadio4, $GUI_UNCHECKED)
	
	GUICtrlSetState($DefaultItem, $GUI_CHECKED)
EndFunc   ;==>SetCheckedItem