VAN0 Posted May 31, 2014 Share Posted May 31, 2014 (edited) Hello.Is there a way prevent menu from closing when clicked on specific menu item?Thank you. expandcollapse popup#include <GuiMenu.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $iMemo Global Enum $idNew = 1000, $idOpen, $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout Example() Func Example() Local $hGUI, $hFile, $hEdit, $hHelp, $hMain ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create memo control $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; Create File menu $hFile = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $idNew) _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $idOpen) _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $idSave) _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $idExit) ; Create Edit menu $hEdit = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $idCut) _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $idCopy) _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $idPaste) ; Create Help menu $hHelp = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $idAbout) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu($MNS_NOTIFYBYPOS) _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit) _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp) ; Set window menu _GUICtrlMenu_SetMenu($hGUI, $hMain) ; Loop until the user exits. GUIRegisterMsg($WM_MENUCOMMAND, "WM_MENUCOMMAND") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; Handle menu commands Func WM_MENUCOMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $ilParam ConsoleWrite($hWnd & @TAB & $iMsg & @TAB & $iwParam & @TAB & $ilParam & @CRLF) ConsoleWrite(_GUICtrlMenu_GetItemText($ilParam, $iwParam) & @CRLF) Switch _GUICtrlMenu_GetItemID($ilParam, $iwParam) Case $idNew MemoWrite("New") Case $idOpen MemoWrite("Open") Case $idSave MemoWrite("Save") Case $idExit Exit Case $idCut MemoWrite("Cut") Case $idCopy MemoWrite("Copy") Case $idPaste MemoWrite("Paste") Case $idAbout MemoWrite("About") EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_MENUCOMMAND ; Write message to memo Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Edited May 31, 2014 by VAN0 Link to comment Share on other sites More sharing options...
FireFox Posted May 31, 2014 Share Posted May 31, 2014 Hi, It may be possible to override the close message through the WM_COMMAND function, if not... maybe subclassing. Br, FireFox. Link to comment Share on other sites More sharing options...
VAN0 Posted May 31, 2014 Author Share Posted May 31, 2014 Thanks. Unfortunately my knowlege is no near there to understand how to override close message or what is subclassing...Any examples where I can look at?P.S.I'm using WM_MENUCOMMAND, updated example in OP Link to comment Share on other sites More sharing options...
VAN0 Posted August 26, 2017 Author Share Posted August 26, 2017 Bumping this topic in hopes someone found a way. Link to comment Share on other sites More sharing options...
Bert Posted August 26, 2017 Share Posted August 26, 2017 you could create a child window with the items listed. That way you have control over it. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now