dickep Posted March 5, 2010 Share Posted March 5, 2010 OK, it is a stretch but I want to have the popup menu item change when you click on it. I have an idea to use it in an application, but need to find out if I can do this. Here is some code I found and modified to try it. Let me know why it just keep adding items - I have an inkling, but.... you can help me expandcollapse popup#Include <Constants.au3> #Include <GUIMenu.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global Enum $idOpen = 1000, $idSave, $idInfo, $idExit global $mThis = 1 $hWnd = GUICreate('') GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, 'Open', $idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, 'Save', $idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, '', 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, 'Info', $idInfo) _GUICtrlMenu_InsertMenuItem($hMenu, 4, 'Exit', $idExit) DllCall('user32.dll', 'int', 'SetForegroundWindow', 'hwnd', $hWnd) while 1 _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd) WEnd _GUICtrlMenu_DestroyMenu($hMenu) Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch $wParam Case $idOpen MsgBox(0, '', 'Open') Case $idSave MsgBox(0, '', 'Save') if $mThis then _GUICtrlMenu_InsertMenuItem($hMenu, 1, 'Not Saved', $idSave) $mThis = not $mThis Else _GUICtrlMenu_InsertMenuItem($hMenu, 1, 'Saved', $idSave) $mThis = not $mThis endif Case $idInfo MsgBox(0, '', 'Info') Case $idExit Exit EndSwitch EndFunc ;==>WM_COMMAND Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2010 Moderators Share Posted March 5, 2010 dickep, Try it this way: If $mThis Then _GUICtrlMenu_SetItemText($hMenu, 1, 'Not Saved') $mThis = Not $mThis Else _GUICtrlMenu_SetItemText($hMenu, 1, 'Saved') $mThis = Not $mThis EndIf 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...
Yoriz Posted March 5, 2010 Share Posted March 5, 2010 expandcollapse popup#Include <Constants.au3> #Include <GUIMenu.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global Enum $idOpen = 1000, $idSave, $idInfo, $idExit global $mThis = 1 $hWnd = GUICreate('') GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, 'Open', $idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, 'Save', $idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, '', 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, 'Info', $idInfo) _GUICtrlMenu_InsertMenuItem($hMenu, 4, 'Exit', $idExit) DllCall('user32.dll', 'int', 'SetForegroundWindow', 'hwnd', $hWnd) while 1 _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd) WEnd _GUICtrlMenu_DestroyMenu($hMenu) Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch $wParam Case $idOpen MsgBox(0, '', 'Open') Case $idSave MsgBox(0, '', 'Save') if $mThis then ;~ _GUICtrlMenu_InsertMenuItem($hMenu, 1, 'Not Saved', $idSave) _GUICtrlMenu_SetItemText ($hMenu, 1, 'Not Saved') $mThis = not $mThis Else ;~ _GUICtrlMenu_InsertMenuItem($hMenu, 1, 'Saved', $idSave) _GUICtrlMenu_SetItemText ($hMenu, 1, 'Saved') $mThis = not $mThis endif Case $idInfo MsgBox(0, '', 'Info') Case $idExit Exit EndSwitch EndFunc ;==>WM_COMMAND GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
dickep Posted March 5, 2010 Author Share Posted March 5, 2010 Again, you come to my aid. I missed the _GUICtrlMenu_SetItemText item in the help file. I looked but, well, to these old eyes they all look alike. Thanks again Melba23, it was something "simple" - like me. E 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