Disable "SubMenu()"?
Disable "SubMenu()"?
Is there a way to disable a submenu item?
This is for a windows app, if it matters.
This is for a windows app, if it matters.
Re: Disable "SubMenu()"?
Yes, that would be for a menuitem(), not a submenu()Droopy wrote:DisableMenuItem ?
-
- Enthusiast
- Posts: 252
- Joined: Mon Aug 16, 2010 4:29 am
Re: Disable "SubMenu()"?
Menu or submenu does not seem to matter with Disable().
Code: Select all
If OpenWindow(0, 200, 200, 220, 100, "SubMenu Example")
If CreateMenu(0, WindowID(0))
MenuTitle("Project")
MenuItem(1, "Open")
MenuItem(2, "Close")
MenuBar()
OpenSubMenu("Recent files") ; begin sub-menu
MenuItem( 3, "C:\Autoexec.bat")
MenuItem( 4, "D:\Test.txt")
CloseSubMenu() ; end sub-menu
EndIf
DisableMenuItem(0, 4, 1) ; disable the second submenu item ("D:\Test.txt")
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Re: Disable "SubMenu()"?
He wants to disable "Recent files", not the menu item inside the sub menu.
Use this:
Use this:
Code: Select all
if OpenWindow(0, 200, 200, 220, 100, "SubMenu Example")
if CreateMenu(0, WindowID(0))
MenuTitle("Project")
MenuItem(1, "Open")
MenuItem(2, "Close")
MenuBar()
handle = OpenSubMenu("Recent files") ; begin sub-menu
MenuItem( 3, "C:\Autoexec.bat")
MenuItem( 4, "D:\Test.txt")
CloseSubMenu() ; end sub-menu
endif
EnableMenuItem_(MenuID(0), handle, #MF_BYCOMMAND | #MF_GRAYED)
repeat
until WaitWindowEvent()=#PB_Event_CloseWindow
endif
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Re: Disable "SubMenu()"?
Great! Thank you.Shield wrote:Code: Select all
EnableMenuItem_(MenuID(0), handle, #MF_BYCOMMAND | #MF_GRAYED)
Re: Disable "SubMenu()"?
Code: Select all
If OpenWindow(0, 200, 200, 220, 100, "SubMenu Example")
If CreateMenu(0, WindowID(0))
MenuTitle("Project")
MenuItem(1, "Open")
MenuItem(2, "Close")
MenuBar()
handle = OpenSubMenu("Recent files") ; begin sub-menu
MenuItem( 3, "C:\Autoexec.bat")
MenuItem( 4, "D:\Test.txt")
CloseSubMenu() ; end sub-menu
EndIf
DisableMenuItem(0, handle, #True)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: Disable "SubMenu()"?
Even slicker!nco2k wrote:Code: Select all
handle = OpenSubMenu("Recent files") ; begin sub-menu DisableMenuItem(0, handle, #True)
Re: Disable "SubMenu()"?
For my own future reference for a PopupImageMenu:
Code: Select all
If OpenWindow(0, 200, 200, 220, 100, "SubMenu Example")
popup = CreatePopupImageMenu(#PB_Any)
If popup
MenuTitle("Project")
MenuItem(1, "Open")
MenuItem(2, "Close")
MenuBar()
sub = OpenSubMenu("Recent files") ; Want this disabled.
MenuItem( 3, "C:\Autoexec.bat")
MenuItem( 4, "D:\Test.txt")
CloseSubMenu()
EndIf
DisableMenuItem(popup, sub, 1)
DisplayPopupMenu(popup, WindowID(0), WindowX(0) + 20, WindowY(0) + 40)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Re: Disable "SubMenu()"?
Hi Barry
Code: Select all
EnableMenuItem_(MenuID(popup), handle, #MF_BYCOMMAND | #MF_GRAYED)
Egypt my love
Re: Disable "SubMenu()"?
Thanks Rashad but I edited my post before you replied, because I worked out it could be done without API.