PhilipG Posted January 6, 2010 Share Posted January 6, 2010 (edited) How do I make a sub menu like (edit/paragraph) in auto it when you run GUI in MessageLoop Mode? I've tried to do it accordingly to the help file but example where running in OnEvent mode. When I tried to run in MessageLoop Mode all the functions that would be activated by the menu buttons got called upon creation!! How could it be done? Edited January 6, 2010 by PhilipG Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2010 Moderators Share Posted January 6, 2010 PhilipG, This works for me: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $mEdit_Menu = GUICtrlCreateMenu("&Edit") $hParagraph_Menu_Item = GUICtrlCreateMenuItem("&Paragraph", $mEdit_Menu) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hParagraph_Menu_Item MsgBox(0, "", "Paragraph Menu Item clicked") EndSwitch WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PhilipG Posted January 6, 2010 Author Share Posted January 6, 2010 So you need to put the getmsg() in a switch? Link to comment Share on other sites More sharing options...
PhilipG Posted January 6, 2010 Author Share Posted January 6, 2010 (edited) PhilipG, This works for me: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $mEdit_Menu = GUICtrlCreateMenu("&Edit") $hParagraph_Menu_Item = GUICtrlCreateMenuItem("&Paragraph", $mEdit_Menu) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hParagraph_Menu_Item MsgBox(0, "", "Paragraph Menu Item clicked") EndSwitch WEnd M23 When I reread your post i noticed that that's not what i'm trying to do! im trying to do something like this: expandcollapse popup;Submenu $sExport = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($sExport, 0, "Exportera Databas", $ExpDB) _GUICtrlMenu_InsertMenuItem ($sExport, 1, "Exportera Uppdrag", $ExpUPD) ;Submenu $sImport = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($sImport, 0, "Importera Databas", $ImpDB) _GUICtrlMenu_InsertMenuItem ($sImport, 1, "Importera Uppdrag", $ImpUPD) ; Create File menu $hAkriv = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hAkriv, 0, "Nytt uppdrag", $nytt) _GUICtrlMenu_InsertMenuItem ($hAkriv, 1, "Öppna uppdrag", $open) _GUICtrlMenu_InsertMenuItem ($hAkriv, 2, "") _GUICtrlMenu_InsertMenuItem ($hAkriv, 3, "Exportera", $export, $sExport) _GUICtrlMenu_InsertMenuItem ($hAkriv, 4, "Importera", 0, $sImport) _GUICtrlMenu_InsertMenuItem ($hAkriv, 5, "") _GUICtrlMenu_InsertMenuItem ($hAkriv, 6, "Stäng av", $exititem) ; Create Edit menu $hRedigera = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hRedigera, 0, "Redigera uppdragsledare", $redupdled) _GUICtrlMenu_InsertMenuItem ($hRedigera, 1, "") _GUICtrlMenu_InsertMenuItem ($hRedigera, 2, "Inställningar", $redigera) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hMain, 0, "Arkiv", 0, $hAkriv) _GUICtrlMenu_InsertMenuItem ($hMain, 1, "Redigera", 0, $hRedigera) ; Set window menu _GUICtrlMenu_SetMenu ($hGUI, $hMain) EDIT: Spelling Edited January 6, 2010 by PhilipG Link to comment Share on other sites More sharing options...
PhilipG Posted January 6, 2010 Author Share Posted January 6, 2010 In help file the script exampel for _GUICtrlMenu_DrawMenuBar does exactly what i want with the $hItem1 Link to comment Share on other sites More sharing options...
ProgAndy Posted January 6, 2010 Share Posted January 6, 2010 (edited) if you want to get the clicks on Menuitems with GUIGetMsg, you have to use the native GUICtrlMenu-functions. An example with a submenu: GUICreate("Menutest") $mnuMain1 = GUICtrlCreateMenu("MainMenu1") $mnuMain1_item1 = GUICtrlCreateMenuItem("Item1", $mnuMain1) $mnuMain1_mnuSub1 = GUICtrlCreateMenu("Submenu1", $mnuMain1) $mnuMain_mnuSub1_Item1 = GUICtrlCreateMenuItem("SubItem1", $mnuMain1_mnuSub1) $mnuMain1_item2 = GUICtrlCreateMenuItem("Item2", $mnuMain1) $mnuMain2 = GUICtrlCreateMenu("MainMenu2") $mnuMain2_item1 = GUICtrlCreateMenuItem("Item1", $mnuMain2) GUISetState() While 1 $uMsg = GUIGetMsg() Switch $uMsg Case -3 ; $GUI_EVENT_CLOSE Exit Case $mnuMain_mnuSub1_Item1 MsgBox(0, '', "Main1 -> Submenu1 .> SubItem1") Case $mnuMain1_item1 MsgBox(0, '', "Main1 -> Item1") Case $mnuMain1_item2 MsgBox(0, '', "Main1 -> Item2") Case $mnuMain2_item1 MsgBox(0, '', "Main2 -> Item1") EndSwitch WEnd Edited January 6, 2010 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 6, 2010 Moderators Share Posted January 6, 2010 (edited) PhilipG,You must use the builtin functions if you want to use GUIGetMsg because you need a ControlID and not a handle. expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $mArkiv_Menu = GUICtrlCreateMenu("Arkiv") $mNytt_uppdrag_Menu_Item = GUICtrlCreateMenuItem("Nytt uppdrag", $mArkiv_Menu) $mOppna_uppdrag_Menu_Item = GUICtrlCreateMenuItem("Öppna uppdrag", $mArkiv_Menu) GUICtrlCreateMenuItem("", $mArkiv_Menu) ; separator line $mExportera_Menu_Item = GUICtrlCreateMenu("Exportera", $mArkiv_Menu) $mExportera_Databas_Menu_Item = GUICtrlCreateMenuItem("Exportera Databas", $mExportera_Menu_Item) $mExportera_Uppdrag_Menu_Item = GUICtrlCreateMenuItem("Exportera Uppdrag", $mExportera_Menu_Item) $mImportera_Menu_Item = GUICtrlCreateMenu("Importera", $mArkiv_Menu) $mImportera_Databas_Menu_Item = GUICtrlCreateMenuItem("Importera Databas", $mImportera_Menu_Item) $mImportera_Uppdrag_Menu_Item = GUICtrlCreateMenuItem("Importera Uppdrag", $mImportera_Menu_Item) GUICtrlCreateMenuItem("", $mArkiv_Menu) ; separator line $mStang_av_Menu_Item = GUICtrlCreateMenuItem("Stäng av", $mArkiv_Menu) $mRedigera_Menu = GUICtrlCreateMenu("Redigera") $mRedigera_uppdragsledare_Menu_Item = GUICtrlCreateMenuItem("Redigera uppdragsledare", $mRedigera_Menu) GUICtrlCreateMenuItem("", $mRedigera_Menu) ; separator line $mInstallningar_Menu_Item = GUICtrlCreateMenuItem("Inställningar", $mRedigera_Menu) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $mNytt_uppdrag_Menu_Item MsgBox(0, "Menu", "Nytt uppdrag") Case $mOppna_uppdrag_Menu_Item MsgBox(0, "Menu", "Oppna uppdrag") Case $mExportera_Databas_Menu_Item MsgBox(0, "Menu", "Exportera Databas") Case $mExportera_Uppdrag_Menu_Item MsgBox(0, "Menu", "Exportera Uppdrag") Case $mImportera_Databas_Menu_Item MsgBox(0, "Menu", "Importera Databas") Case $mImportera_Uppdrag_Menu_Item MsgBox(0, "Menu", "Importera Uppdrag") Case $mStang_av_Menu_Item MsgBox(0, "Menu", "Stang av") Case $mRedigera_uppdragsledare_Menu_Item MsgBox(0, "Menu", "Redigera uppdragsledare") Case $mInstallningar_Menu_Item MsgBox(0, "Menu", "Installningar") EndSwitch WEndM23Edit: As ProgAndy has just told you! Edited January 6, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PhilipG Posted January 6, 2010 Author Share Posted January 6, 2010 (edited) if you want to get the clicks on Menuitems with GUIGetMsg, you have to use the native GUICtrlMenu-functions. An example with a submenu: GUICreate("Menutest") $mnuMain1 = GUICtrlCreateMenu("MainMenu1") $mnuMain1_item1 = GUICtrlCreateMenuItem("Item1", $mnuMain1) $mnuMain1_mnuSub1 = GUICtrlCreateMenu("Submenu1", $mnuMain1) $mnuMain_mnuSub1_Item1 = GUICtrlCreateMenuItem("SubItem1", $mnuMain1_mnuSub1) $mnuMain1_item2 = GUICtrlCreateMenuItem("Item2", $mnuMain1) $mnuMain2 = GUICtrlCreateMenu("MainMenu2") $mnuMain2_item1 = GUICtrlCreateMenuItem("Item1", $mnuMain2) GUISetState() While 1 $uMsg = GUIGetMsg() Switch $uMsg Case -3 ; $GUI_EVENT_CLOSE Exit Case $mnuMain_mnuSub1_Item1 MsgBox(0, '', "Main1 -> Submenu1 .> SubItem1") Case $mnuMain1_item1 MsgBox(0, '', "Main1 -> Item1") Case $mnuMain1_item2 MsgBox(0, '', "Main1 -> Item2") Case $mnuMain2_item1 MsgBox(0, '', "Main2 -> Item1") EndSwitch WEnd I Thought i tried that without success. But when I look closer on your code i noticed what i've done wrong! This was my code: $arkiv = GUICtrlCreateMenu ( "Akriv");skapar en $export = GUICtrlCreateMenuitem("Exportera", $arkiv) $exportDB = GUICtrlCreateMenuItem("Databas", $export) Now corrected it to: $arkiv = GUICtrlCreateMenu ( "Akriv");skapar en $export = GUICtrlCreateMenu("Exportera", $arkiv) $exportDB = GUICtrlCreateMenuItem("Databas", $export) And now it all works fine! Thanks! Edited January 6, 2010 by PhilipG 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