I make the request having just found a need for such a command. Using api is no problem, but still...
SetSubmenuText()
SetSubmenuText()
We have SetMenuItemText() and SetMenuTitleText(), but no equivalent for setting a submenu text!
I make the request having just found a need for such a command. Using api is no problem, but still...
I make the request having just found a need for such a command. Using api is no problem, but still...
I may look like a mule, but I'm not a complete ass.
Don't you just use SetMenuItemText with the number of the entry you want to change. Altered from the PB example.
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
SetMenuItemText(0,4,"THIS IS CHANGED") ; <---- change the sub item text
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf%101010 = $2A = 42
Uhm look at Perkin's code!Mistrel wrote:Would this function be cross-platform? I'm not sure what you mean by "submenu text" or "recent files" so I have to ask. Would you provide an example?
@Perkin : here is how to use api to alter the submenu title's text. I avoid using the obsolete ModifyMenu_() :
Code: Select all
#MainMenu = 0
If OpenWindow(0, 200, 200, 220, 100, "SubMenu Example")
If CreateMenu(#MainMenu, 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
MenuTitle("Edit")
MenuItem(5, "Copy")
EndIf
;Change the "Recent files" submenu text.
mii.MENUITEMINFO
With mii
\cbSize = SizeOf(MENUITEMINFO)
\fMask = #MIIM_TYPE
\fType = #MFT_STRING
\dwTypeData = @"Heyho!"
EndWith
hSubMenu = GetSubMenu_(MenuID(#MainMenu), 0)
SetMenuItemInfo_(hSubmenu, 3, #True, mii)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIfI may look like a mule, but I'm not a complete ass.
Ahhh; I did a search through the Feature requests forum but could find nothing.Berikco wrote:This was asked a few years ago i remember, and confirmed by Fred it would be added......i guess it slipped Fred's mind
You have a good memory there Bericko!
I may look like a mule, but I'm not a complete ass.
- DoubleDutch
- Addict

- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Is the API command ModifyMenu_ now deprecated?
If so, what should you use across Win95 to Win7 that does this:
If so, what should you use across Win95 to Win7 that does this:
Code: Select all
ModifyMenu_(i_CurrentMenu,item,#MF_BYCOMMAND|#MF_OWNERDRAW,item,i_CurrentMenu)https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
- DoubleDutch
- Addict

- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
This post indirectly inspired me to add recent files to Elementary Reports:
http://forum.computingdata.com/viewtopic.php?f=3&t=162
I've done it a different way though, the menu is ownerdrawn so it's much easier to change things. The addition I made to my menusize/menudraw system is that if the text is empty, then menu item has a height of zero!
So I just setup 10 'recent files' and set the default text to "", when it's not "" then the height becomes normal and the menu item is visible.
As an added bonus I use the normal key 'thingy' (the bit after a tab) to display the date that the file was last accessed.
http://forum.computingdata.com/viewtopic.php?f=3&t=162
I've done it a different way though, the menu is ownerdrawn so it's much easier to change things. The addition I made to my menusize/menudraw system is that if the text is empty, then menu item has a height of zero!
So I just setup 10 'recent files' and set the default text to "", when it's not "" then the height becomes normal and the menu item is visible.
As an added bonus I use the normal key 'thingy' (the bit after a tab) to display the date that the file was last accessed.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
Re: SetSubmenuText()
@srod
thanks for the workaround.
c ya,
nco2k
thanks for the workaround.
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf


