DarkOnyx Posted December 13, 2013 Share Posted December 13, 2013 Hi everyone. I have just found this software and I must say that it's magnificent. I am teaching myself through various code examples and I created a basic GUI. Cool. I was looking at this example here: =======================================================================================#include <GUIConstantsEx.au3>#include <ButtonConstants.au3>Example1()Example2(); ****************; * First sample *; ****************Func Example1() ;right click on gui to bring up context Menu. ;right click on the "ok" button to bring up a controll specific context menu. GUICreate("My GUI Context Menu", 300, 200) Local $contextmenu = GUICtrlCreateContextMenu() Local $button = GUICtrlCreateButton("OK", 100, 100, 70, 20) Local $buttoncontext = GUICtrlCreateContextMenu($button) GUICtrlCreateMenuItem("About button", $buttoncontext) Local $newsubmenu = GUICtrlCreateMenu("new", $contextmenu) GUICtrlCreateMenuItem("text", $newsubmenu) GUICtrlCreateMenuItem("Open", $contextmenu) GUICtrlCreateMenuItem("Save", $contextmenu) GUICtrlCreateMenuItem("", $contextmenu) ; separator GUICtrlCreateMenuItem("Info", $contextmenu) GUISetState() ; Run the GUI until the dialog is closed While 1 Local $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete()EndFunc ;==>Example1 ======================================================================================= I see that it creates a simple right click menu. Very nice. But none of the controls actually do anything so I am having trouble understanding that next step. I'd experimented with switch/case and haven't had that much luck on making any new breakthroughs in my understanding. Which command allows the "Info" button on the right click menu execute a command? Where should I start looking? Thanks. Link to comment Share on other sites More sharing options...
l3ill Posted December 13, 2013 Share Posted December 13, 2013 Hi DarkOnyx, and welcome to the forum! Switch case was the correct place to look. Now just get a working example of some code using these and play around with it until you see how it works, then start changing to do what you want. I just posted just such an >example. The buttons used are different from the Context Menu but same basic concept. Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
l3ill Posted December 13, 2013 Share Posted December 13, 2013 Here a simple example to get you started: expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> GUICreate("My GUI Context Menu", 300, 200) Local $case_0, $case_1, $case_2, $case_3 Local $contextmenu = GUICtrlCreateContextMenu() Local $button = GUICtrlCreateButton("OK", 100, 100, 70, 20) Local $buttoncontext = GUICtrlCreateContextMenu($button) GUICtrlCreateMenuItem("About button", $buttoncontext) Local $newsubmenu = GUICtrlCreateMenu("new", $contextmenu) GUICtrlCreateMenuItem("text", $newsubmenu) $case_0 = GUICtrlCreateMenuItem("Case 0", $contextmenu) $case_1 = GUICtrlCreateMenuItem("Case 1", $contextmenu) GUICtrlCreateMenuItem("", $contextmenu) ; separator $case_2 = GUICtrlCreateMenuItem("Case 2", $contextmenu) $case_3 = GUICtrlCreateMenuItem("Case 3", $contextmenu) GUICtrlCreateMenuItem("Info", $contextmenu) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $case_0 MsgBox(0, "Case 0", "This is Case 0") Case $case_1 MsgBox(0, "Case 1", "This is Case 1") Case $case_2 _Function_case_2() Case $case_3 MsgBox(0, "Case 3", "This is Case 3") EndSwitch WEnd Func _Function_case_2() MsgBox(0, "Case 2", "This is Function Case 2") EndFunc My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
DarkOnyx Posted December 13, 2013 Author Share Posted December 13, 2013 Thanks so much for taking the time to help me get started! I'll play around with the code and see what happens. Thanks again! Link to comment Share on other sites More sharing options...
DarkOnyx Posted December 13, 2013 Author Share Posted December 13, 2013 Aha! Opt("GUIOnEventMode", 1) did something that made the menus not work. Interesting... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 13, 2013 Moderators Share Posted December 13, 2013 DarkOnyx,You can only run either OnEvent or MessageLoop mode at one time in a script. So if you want to run the script in OnEvent mode you will need to assign event functions to each of the active menu items using GUICtrlSetOnEvent. 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...
l3ill Posted December 13, 2013 Share Posted December 13, 2013 The "aha" moment !! reminds of those chinese people that invented dynamite... and the ones watching from a safe distance that took all the credit for it My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
DarkOnyx Posted December 14, 2013 Author Share Posted December 14, 2013 It works great now! Headache eliminated.... Of course, there's only one thing to do now... GO ON TO THE NEXT HEADACHE INDUCING CODE! 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