It is currently Thu Nov 21, 2019 2:09 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Disable "SubMenu()"?
PostPosted: Mon Dec 31, 2012 7:43 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Feb 17, 2010 12:00 am
Posts: 1324
Location: (Embarrassed to say country)
Is there a way to disable a submenu item?
This is for a windows app, if it matters.


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Mon Dec 31, 2012 8:13 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Sep 16, 2004 9:50 pm
Posts: 658
Location: France
DisableMenuItem ?

_________________
DroopyLib/PBFastLib/HMod


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Tue Jan 01, 2013 4:54 am 
Offline
Addict
Addict
User avatar

Joined: Wed Feb 17, 2010 12:00 am
Posts: 1324
Location: (Embarrassed to say country)
Droopy wrote:
DisableMenuItem ?


Yes, that would be for a menuitem(), not a submenu()


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Tue Jan 01, 2013 5:45 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Aug 16, 2010 4:29 am
Posts: 252
Menu or submenu does not seem to matter with Disable().
Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Tue Jan 01, 2013 6:39 am 
Offline
Addict
Addict
User avatar

Joined: Fri Jan 21, 2011 8:25 am
Posts: 1021
Location: 'stralia!
He wants to disable "Recent files", not the menu item inside the sub menu.
Use this:

Code:
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

_________________
Image
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Tue Jan 01, 2013 9:16 am 
Offline
Addict
Addict
User avatar

Joined: Wed Feb 17, 2010 12:00 am
Posts: 1324
Location: (Embarrassed to say country)
Shield wrote:
Code:
   EnableMenuItem_(MenuID(0), handle, #MF_BYCOMMAND | #MF_GRAYED)


Great! Thank you.


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Tue Jan 01, 2013 11:54 am 
Offline
Addict
Addict
User avatar

Joined: Mon Sep 15, 2003 5:55 am
Posts: 1341
Code:
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
c ya,
nco2k

_________________
If OSVersion() = #PB_OS_Windows_ME : End : EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Tue Jan 01, 2013 8:46 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Feb 17, 2010 12:00 am
Posts: 1324
Location: (Embarrassed to say country)
nco2k wrote:
Code:
      handle = OpenSubMenu("Recent files")       ; begin sub-menu
     DisableMenuItem(0, handle, #True)


Even slicker!


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Wed Jun 12, 2019 5:10 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 394
For my own future reference for a PopupImageMenu:

Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Wed Jun 12, 2019 5:18 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3457
Hi Barry

Code:
EnableMenuItem_(MenuID(popup), handle, #MF_BYCOMMAND | #MF_GRAYED)

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Disable "SubMenu()"?
PostPosted: Wed Jun 12, 2019 5:52 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 394
Thanks Rashad but I edited my post before you replied, because I worked out it could be done without API. :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: gonpublic2k and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye