MacScript Posted August 10, 2014 Posted August 10, 2014 HI there, I was wondering if there is a way to hide a menu option that is part of a context menu. For instance when you right click on the body of this gui and set Readonly = Yes. Then I want the COntext Menu for New to be Hidden (Not disabled/greyed out). Is there any way to do this? expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI Context Menu", 300, 200) Local $idContextmenu = GUICtrlCreateContextMenu() Global $CtxMenuTrans = GUICtrlCreateMenu("Read Only", $idContextmenu) ;-45a- Global $CtxMenuNo = GUICtrlCreateMenuItem("No", $CtxMenuTrans, -1, 1) ;-49b- Global $CtxMenuYes = GUICtrlCreateMenuItem("Yes", $CtxMenuTrans, -1, 1) ;-49b- GUICtrlSetState($CtxMenuNo, $GUI_CHECKED) ;-49b- Local $idNewsubmenu = GUICtrlCreateMenu("new", $idContextmenu) Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu) Local $idButton = GUICtrlCreateButton("OK", 100, 100, 70, 20) Local $idButtoncontext = GUICtrlCreateContextMenu($idButton) Local $idMenuAbout = GUICtrlCreateMenuItem("About button", $idButtoncontext) Local $idMenuOpen = GUICtrlCreateMenuItem("Open", $idContextmenu) Local $idMenuSave = GUICtrlCreateMenuItem("Save", $idContextmenu) GUICtrlCreateMenuItem("", $idContextmenu) ; separator Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $CtxMenuNo ;----> Show the Control $idNewsubmenu <---- Case $CtxMenuyes ;----> HIDE the Control $idNewsubmenu <---- Case $GUI_EVENT_CLOSE ExitLoop Case $idButton MsgBox($MB_SYSTEMMODAL, "Button Clicked", 'OK') Case $idMenuAbout MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'About') Case $idMenuOpen MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Open') Case $idMenuSave MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Save') Case $idMenuInfo MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Info') Case $idNewsubmenuText MsgBox($MB_SYSTEMMODAL, "SubMenu Selected", 'Text') EndSwitch WEnd GUIDelete() EndFunc ;==>Example Thanks in advance for any help / suggestions that are provided
MikahS Posted August 11, 2014 Posted August 11, 2014 (edited) This will hide the control that you pass to it (I passed the new context menu per your question): GUICtrlSetState($idNewsubmenu, 32) Here is the helpfile link EDIT: you would add this to your case statement that when pressed; you want it to do this ^ Edited August 11, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
MacScript Posted August 11, 2014 Author Posted August 11, 2014 Seeker -> Guictrlstate will not work on contextmenu as can be seen by the statement in the link you provided -> "State of a "contextmenu" control cannot be changed.". Thanks for your suggestion but need a different one.
MikahS Posted August 12, 2014 Posted August 12, 2014 Understood, should have looked ><, I will keep looking Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
MikahS Posted August 12, 2014 Posted August 12, 2014 There is no way to change the state; the only thing that can be done is to actually delete them and then re-add them. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
MikahS Posted August 12, 2014 Posted August 12, 2014 This will essentially 'hide' it by deleting it. If you need to re-add it then you'll need to create it again.GUICtrlDelete($idNewsubmenu) Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
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