vacko Posted May 28, 2012 Share Posted May 28, 2012 Hi, I have some GUI with context menu and with many text labels, but context menu doesn't work when mouse cursor stay above some of these labels. Is it possible change GUI to let context menu works in any place ? Example is below #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form2 = GUICreate("Form2", 347, 137) $Group1 = GUICtrlCreateGroup("Context menu doesn't work here", 8, 72, 329, 57) $Label1 = GUICtrlCreateLabel("SomeLabelSomeLabelSome", 16, 88, 316, 33) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Local $contextmenu = GUICtrlCreateContextMenu() $ContextMenuItem1 = GUICtrlCreateMenuItem("Open" &@TAB&"Alt+O", $contextmenu) $ContextMenuItem2 = GUICtrlCreateMenuItem("Exit" &@TAB&"Alt+X", $contextmenu) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ContextMenuItem2 Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
armoros Posted May 28, 2012 Share Posted May 28, 2012 Hello vackofrom help file RemarksAfter creating the context menu main control with this function, each menu item can be created by using GUICtrlCreateMenuItem.Sub-menus can be created using GUICtrlCreateMenu.If you use no parameters or -1 in this function then the context menu that is created is associated with the entire GUI window rather than an individual control.Only one context menu per control is possible. If you wish to create a new context menu one you have to delete the existing menu first.Note: You can't create context menus for controls that already have system context menus, i.e. edit or input controls. [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
vacko Posted May 28, 2012 Author Share Posted May 28, 2012 Hello vackofrom help file RemarksAfter creating the context menu main control with this function, each menu item can be created by using GUICtrlCreateMenuItem.Sub-menus can be created using GUICtrlCreateMenu.If you use no parameters or -1 in this function then the context menu that is created is associated with the entire GUI window rather than an individual control.Only one context menu per control is possible. If you wish to create a new context menu one you have to delete the existing menu first.Note: You can't create context menus for controls that already have system context menus, i.e. edit or input controls.I don't get it, I didn't use any parameter, so context menu should apply to entire GUI (include all controls), isn't it ? Link to comment Share on other sites More sharing options...
armoros Posted May 28, 2012 Share Posted May 28, 2012 (edited) vacko as i get it you can have 1 context menu for a control etc. I made a mistake vacko sorry..so i deleted the code.. I am not a expert so wait for a better advice Edited May 28, 2012 by armoros [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
stormbreaker Posted May 28, 2012 Share Posted May 28, 2012 I don't have much time for now... But I suggest you create a dummy control, set its context menu and modify ShowMenu() function (from GuiCtrlCreateContextMenu example in help file) according to your needs (I could do it, but I guess it would be fun doing it yourself..) A bit modification and the context menu could then be displayed on any control... ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 28, 2012 Moderators Share Posted May 28, 2012 vacko,The context menu does not fire when over the label because the label is reagrded as a separate control which could well have its own context menu. If you remove the default $SS_NOTIFY style from the label it is no longer regarded as a separate control and the GUI context menu will appear: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form2 = GUICreate("Form2", 347, 137) $Group1 = GUICtrlCreateGroup("Context menu doesn't work here", 8, 72, 329, 57) $Label1 = GUICtrlCreateLabel("SomeLabelSomeLabelSome", 16, 88, 316, 33) GUICtrlSetStyle(-1, $SS_LEFT) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Local $contextmenu = GUICtrlCreateContextMenu() $ContextMenuItem1 = GUICtrlCreateMenuItem("Open" & @TAB & "Alt+O", $contextmenu) $ContextMenuItem2 = GUICtrlCreateMenuItem("Exit" & @TAB & "Alt+X", $contextmenu) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ContextMenuItem2 Exit EndSwitch WEndAll clear? 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...
armoros Posted May 28, 2012 Share Posted May 28, 2012 That is great info Mkish and Melba23.....nice to know. [font="verdana, geneva, sans-serif"] [/font] Link to comment Share on other sites More sharing options...
vacko Posted May 28, 2012 Author Share Posted May 28, 2012 vacko,The context menu does not fire when over the label because the label is reagrded as a separate control which could well have its own context menu. If you remove the default $SS_NOTIFY style from the label it is no longer regarded as a separate control and the GUI context menu will appear: All clear? M23Great ! Thank you for help.I have over 30 labels in my GUI, now just modify them... 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