HideMenuItem() ?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
ebs
Enthusiast
Enthusiast
Posts: 556
Joined: Fri Apr 25, 2003 11:08 pm

HideMenuItem() ?

Post by ebs »

It would be great if there was a HideMenuItem() command, similar to the
existing DisableMenuItem().

I just added a most recently used (MRU) file list to the menu in a Visual Basic project.
It was easy since VB has this command.

Does anyone have any suggestions how to do this in PureBasic?
Without having to delete and re-create the menu each time the MRU list needs to change, of course.
API solutions for Windows would be OK, since that's the only platform I need to support.

Thanks,
Eric
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: HideMenuItem() ?

Post by uwekel »

That's exactly what i needed today for the same reason. Any chance to get it within the next 6 years? ;-)
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: HideMenuItem() ?

Post by skywalk »

Why is recreating the menu NOT an option?
If you plan to do this, just make a structured array of your menuitems and each item status and loop through in a blink.
You can tuck all this menu stuff in a procedure that handles all your menu possibilities.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: HideMenuItem() ?

Post by uwekel »

Ok that works, but really, it is more than common to have such commands to remove or at least hide menu items. It is not just recreating the menu but also restore the menu item disabled states, images and so on. Just to hide one item...
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: HideMenuItem() ?

Post by Tenaja »

I will +1 this, and add another request...

AddMenuItem() ; Adds an item to a random menu
MenuItemCount() ; Returns the number of items in a Menu

These few features will make adding plug-ins to the menu much simpler.
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: HideMenuItem() ?

Post by charvista »

In one word: a complete menu editor :mrgreen:
+1
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: HideMenuItem() ?

Post by MachineCode »

+1 to this request... I need to hide a menu item today but have to look for an API solution.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: HideMenuItem() ?

Post by Keya »

+1! But perhaps it's not possible cross-OS to hide a child menu item without recreating the menu?
The following fails to hide the child menu:

Code: Select all

Enumeration FormMenu
  #mnuParent
  #mnuChild
EndEnumeration

Procedure OpenDlg1(x = 0, y = 0, width = 390, height = 220)
  OpenWindow(0, x, y, width, height, "Hide Child Menu", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CreateMenu(0, WindowID(0))
  MenuTitle("Menu")
  OpenSubMenu("Parent")
  MenuItem(#mnuChild, "Child")
  CloseSubMenu()
  HideMenu(#mnuChild,1)
EndProcedure

Procedure Dlg1_Events(event)
   ProcedureReturn #True
EndProcedure

OpenDlg1()
Repeat
   Event = WaitWindowEvent()
   Dlg1_Events(Event)       
Until Event = #PB_Event_CloseWindow
User avatar
mhs
Enthusiast
Enthusiast
Posts: 101
Joined: Thu Jul 02, 2015 4:53 pm
Location: Germany
Contact:

Re: HideMenuItem() ?

Post by mhs »

+1
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: HideMenuItem() ?

Post by Dude »

skywalk wrote:Why is recreating the menu NOT an option?
Low memory is one reason. Just because a menu was created successfully at the start of your app, doesn't mean you'll be able to recreate it again later.

Besides, what you're asking is the same as asking why NOT recreate the entire GUI for your app when you just want to change the text on a button. ;)
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: HideMenuItem() ?

Post by Bisonte »

Maybe DisableMenu() is an option ?

Most commercial products only disable not relevant menu items....
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Post Reply