TheAutomator Posted May 8 Share Posted May 8 (edited) simple example: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) $menu1 = GUICtrlCreateMenu("click me") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $menu1 MsgBox(64,'yes!','it works') ; not EndSwitch WEnd To make this work without submenus/empty menu tricks seems to be difficult Not possible without dummy's / extensive UDF's or submenus? TheAutomator Edited May 8 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
Nine Posted May 8 Share Posted May 8 Here one way : #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> Opt("MustDeclareVars", True) Global $hGUI = GUICreate("Form1", 625, 442, 370, 232) Global $idMenu = GUICtrlCreateMenu("Click me") Global $hMenu = _GUICtrlMenu_GetMenu($hGUI) Global $idChoice = GUICtrlCreateDummy() GUISetState() GUIRegisterMsg($WM_MENUSELECT, WM_MENUSELECT) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idChoice ConsoleWrite("Menu clicked " & GUICtrlRead($idChoice) & @CRLF) EndSwitch WEnd Func WM_MENUSELECT($hWnd, $iMsg, $wParam, $lParam) Local $iIndex = _WinAPI_LoWord($wParam) Local $iFlag = _WinAPI_HiWord($wParam) If $iIndex = 0 And BitAND($iFlag, $MF_MOUSESELECT) And $lParam = $hMenu Then GUICtrlSendToDummy($idChoice, $iIndex) EndMenu() EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_MENUSELECT Func EndMenu() DllCall("user32.dll", "bool", "EndMenu") EndFunc TheAutomator 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted May 8 Moderators Solution Share Posted May 8 TheAutomator, The trick I have used in the past only works when you to have an initial "normal" menu entry - so how about this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) $mDummymenu = GUICtrlCreateMenu("") $menu1 = GUICtrlCreateMenuItem("click me", -1) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $menu1 MsgBox(64,'yes!','it works') ; does! EndSwitch WEnd M23 SOLVE-SMART 1 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...
Nine Posted May 8 Share Posted May 8 Nice trick M23, to make it more like modern menu how about using this character (instead of null) : $mDummymenu = GUICtrlCreateMenu("≡") TheAutomator, SOLVE-SMART and Melba23 3 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
TheAutomator Posted May 8 Author Share Posted May 8 (edited) I guess the short answer is "nope", I tend to use the one from Melba32 for simplicity (and marked it as solution to close the topic), but you have to have a clickable empty menu in your gui.. The one Nine posted was a little more complicated and used a dummy and udf's, but it looks the way it should when used.. I can't really call any reply's the right 'solution' because the question was "possible without dummy's, udf's or submenu/second menu tricks?". But I wanna thank you all for coming up with workarounds, now at least I know I'm not doing anything wrong in my code TheAutomator Edited May 8 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
Nine Posted May 9 Share Posted May 9 Can you show us YOUR solution without dummy, udf, menu/submenu, etc ? I am really curious to see how you got it working, and community sure would appreciate to learn from it too... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted May 9 Share Posted May 9 @Melba23 & @Nine Deleting the menu control seems to do the job. It will position to the very left of the GUI all existing menuitem(s) control(s) . Does this work for you ? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) $mDummymenu = GUICtrlCreateMenu("this menu control will be deleted") $menu1 = GUICtrlCreateMenuItem("click me", -1) $menu2 = GUICtrlCreateMenuItem("click me again", -1) GUICtrlDelete($mDummymenu) ; <====================== GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $menu1 MsgBox($MB_TOPMOST ,'yes!', 'it works') Case $menu2 MsgBox($MB_TOPMOST,'yes!', 'it works again') EndSwitch WEnd TheAutomator, Nine, Melba23 and 1 other 4 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9 Moderators Share Posted May 9 pixelsearch, Nice one! 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...
TheAutomator Posted May 15 Author Share Posted May 15 (edited) Dear Nine, On 5/9/2024 at 2:27 AM, Nine said: Can you show us YOUR solution without dummy, udf, menu/submenu, etc ? I am really curious to see how you got it working, and community sure would appreciate to learn from it too... I think you misunderstood the question.. I wanted to know if it was possible, I'm not saying it is possible The solution seems to be to do it like Melba32 or pixelsearch or you The answer to my question would be "sorry, not possible" do you know what I mean? Edited May 15 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
TheAutomator Posted May 15 Author Share Posted May 15 (edited) And now here we can even reuse the variable, gonna do it like this. Thanks pixelsearch! #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) $menu2 = GUICtrlCreateMenu("this menu control will be deleted") $menu1 = GUICtrlCreateMenuItem("click me", -1) GUICtrlDelete($menu2) ; <====================== $menu2 = GUICtrlCreateMenuItem("click me again", -1) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $menu1 MsgBox($MB_TOPMOST ,'yes!', 'it works') Case $menu2 MsgBox($MB_TOPMOST,'yes!', 'it works again') EndSwitch WEnd Edited May 15 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
TheAutomator Posted May 15 Author Share Posted May 15 (edited) On 5/9/2024 at 3:32 PM, pixelsearch said: @Melba23 & @Nine Deleting the menu control seems to do the job. It will position to the very left of the GUI all existing menuitem(s) control(s) . Does this work for you ? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) $mDummymenu = GUICtrlCreateMenu("this menu control will be deleted") $menu1 = GUICtrlCreateMenuItem("click me", -1) $menu2 = GUICtrlCreateMenuItem("click me again", -1) GUICtrlDelete($mDummymenu) ; <====================== GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $menu1 MsgBox($MB_TOPMOST ,'yes!', 'it works') Case $menu2 MsgBox($MB_TOPMOST,'yes!', 'it works again') EndSwitch WEnd This is an awesome hack btw Edited May 15 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone 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