Re: Dynamic Menu Creation & Destroying them after each session

new topic     » goto parent     » topic index » view thread      » older message » newer message

Greg Haberek wrote:
> 
> > Is there any way I can get the MenuItemID's of the parent MenuID?
> 
> Its pretty simple. Just get the count of items, then walk through
> grabbing each ID. I just whipped this up in GMail, it might not work
> entirely:
> 

Finally I cracked it. Using C K Lester's FastMenu (with little modification)
and the functions available in that include, I could destroy the user
specific menu at the end of each successful session and regenerate it again
for the next session.

Following is the code:

==========================================================


function destroyMenu(atom itemID, sequence item)
	atom childID
	sequence s
	for i = 1 to length(item) do
		s = item[i]
		if not allAtoms(s) then -- from FastMenu
			childID = getMenuID(s[1]) -- from FastMenu
--			InfoWindow("SubMenu" & sprintf("%d", i) & " ID: " & sprintf("%d", childID)
& " : " & s[1])
			void = destroyMenu(childID, s[2])
		else
			childID = getMenuID(s)
--			InfoWindow("MenuItem" & sprintf("%d", i) & " ID: " & sprintf("%d", childID)
& " : " & s)
		end if
		destroy(childID)
	end for
	return w32True
end function

procedure MainMenu_onClose (integer self, integer event, sequence
params)--params is ()
	atom		childID

	for i = 1 to length(user_menu) do -- user_menu is input for FastMenu
		childID = getMenuID(user_menu[i][1]) -- from FastMenu
--		InfoWindow("MenuBar" & sprintf("%d", i) & " ID: " & sprintf("%d", childID) &
" : " & user_menu[i][1])
		void = destroyMenu(childID, user_menu[i][2])
		destroy(childID)
		refreshWindow(MainMenu)
	end for

end procedure
setHandler( MainMenu, w32HClose, routine_id("MainMenu_onClose"))


==========================================================

CK, I was wondering whether destroyMenu() can be included into FastMenu
as a function itself.

Thanks to all you guys, Pete Lomax, Greg Haberek, Bernie Ryan,
Alex Chamberlain... for giving me insight into the problem,
it really helped me to learn.

Regards,
Rad.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu