I created an include, where i wanted to do anything dynamically to not interfere with any mainprogram.
Then i recognized, that it is not possible to create dynamic MenuItems...!?
MenuItem(#PB_Any, ...)
Re: MenuItem(#PB_Any, ...)
+1
and same like:
FreeMenuItem() oder RemoveMenuItem(), to delete one Item, and not the whole Menu and create all others new.
and same like:
FreeMenuItem() oder RemoveMenuItem(), to delete one Item, and not the whole Menu and create all others new.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: MenuItem(#PB_Any, ...)
On Windows, menu items must fit in an usignedword-sized variable (Purebasic .u). One approach could be 0-32767 are available static menuitem #'s and #PB_Any would select from 32768-66535. Workable and probably useful for Windows, imho. No idea on other OS's.
Entirely different topic, no?STARGÅTE wrote:and same like:
FreeMenuItem() oder RemoveMenuItem(), to delete one Item, and not the whole Menu and create all others new.
BERESHEIT
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: MenuItem(#PB_Any, ...)
You mean 65535, yes?netmaestro wrote:#PB_Any would select from 32768-66535

Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: MenuItem(#PB_Any, ...)
WorkAround:
Is not native, but better as nothing
Greetings - Thomas
Code: Select all
EnableExplicit
Procedure MyMenuitem(ID, Text.s, ImageID = 0)
Static Dim IDs(65535)
Protected I
If ID <> #PB_Any
If IDs(ID) <> 1
MenuItem(ID, Text, ImageID)
IDs(ID) = 1
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
Else
For I = 65535 To 0 Step -1
If IDs(I) = 0
IDs(I) = 1
MenuItem(I, Text, ImageID)
ProcedureReturn I
EndIf
Next
ProcedureReturn #False
EndIf
EndProcedure
Macro MenuItem(a, b, c = 0)
MyMenuitem(a, b, c)
EndMacro
Define mnuSave, mnuClose
OpenWindow(0, #PB_Ignore, #PB_Ignore, 640, 480, "")
If CreateMenu(0, WindowID(0))
MenuTitle("Project")
MenuItem(1, "Open")
mnuSave = MenuItem(#PB_Any, "Save")
MenuItem(3, "Save as"+Chr(9)+"Ctrl+A")
mnuClose = MenuItem(#PB_Any, "Close")
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow : Break
Case #PB_Event_Menu
Select EventMenu()
Case 1 : Debug "Open"
Case 3 : Debug "Save As"
Case mnuSave : Debug "Save"
Case mnuClose : Debug "Close"
EndSelect
EndSelect
ForEver
Greetings - Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
