Re: Dynamic Menu Creation & Destroying them after each session

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

Hi Pete,

Thanks for your reply.

Let me give you the background of what I am trying to do.

I am trying to develop a multi-user application where each user will log in to
the application via user-id/password combination. Depending on his access rights
to various options within the application, a dynamic menu will be built after his
successful login. Once he logs off, the menu will be destroyed and control will
come back to earlier log-in screen for other/ same user to go in. Each time
depending on logged-in user's access rights, a dynamic menu will be available for
that single user session.
(Though currently I am loading all the menu options for any user and trying to
remove menu after log off.)

Now, the way I went ahead with it - using EuVIDE, win32lib and FASTMENU by
c.k.lester. At the closure of main application window (where menu is built) and
before going back to log-in window, I am trying to destroy the user specific
menu/menu items, without which menu bar is appended with same multiple menu
options for each new session.

My menu structure is as follows:

System (Menu) --> Categories (Sub-menu) --> Category Maintenance (Menu Item)
                                        --> Category List (Menu Item)
|            |
|            |
|             --> Users (Sub-menu) --> User Maintenance (Menu Item)
|                                  --> User List (Menu Item)
|
Log-out (Menu) --> Exit (Menu Item)

I tried to follow the logic in ARWEN destroyMenu function. Got the MenuID
(System, Log-out) properly, but got stuck at Menu Items.
E.g. For System menu, got xGetMenuItemCount properly as 2, but could not call
destroyMenu recursively with proper MenuItem IDs. xGetMenuItemID fails. Got some
number mID.

Is there any way I can get the MenuItemID's of the parent MenuID? 

Following is the code I am using:

procedure MainMenu_onClose (integer self, integer event, sequence
params)--params is ()
	sequence children
    -- Get a list of all the controls owned by this window

    children = findChildren(MainMenu)

    -- Delete all the Menus
    for i = 1 to length(children) do
		if find(children[i][2],{Menu}) then
			void = destroyMenu(children[i][2])
		end if
	end for
	
	openWindow({LogInWin, Combo20}, Normal)
end procedure
. 
. 
. 
. 
global function destroyMenu(atom id)
	atom hMenu, hsubMenu
	integer count, mID
	sequence submenus

	if id = Menu then
		hMenu = getHandle(id)

		-- first, destroy any menuitems
		count = c_func(xGetMenuItemCount, {hMenu})
		for i = count to 1 by -1 do
			mID = c_func(xGetMenuItemID, {hMenu, i})
			if mID != #FFFFFFFF then -- valid id obtained
				void = destroyMenu(mID)
			end if
		end for
		-- second, destroy the menu
		void = c_func(xDestroyMenu, {hMenu} )
		return True

	-- destroy a single menuitem
	elsif id = MenuItem then --or id = MenuSep then
	     void = c_func(xRemoveMenu, {getParentHwnd(id), id, MF_BYCOMMAND})
		return True
	end if
	return True
end function


I get mID as a number which fails in xGetMenuItemID with "type_check failure,
mID is 4294967295" error.
Also I am not sure about the xRemoveMenu parameters (getParentHwnd ?). 

Where can I get detailed documentation on xGet..... functions?

Regards,
Rad.

-----Original Message-----
 From: Pete Lomax [mailto:petelomax at blueyonder.co.uk] 
Sent: 13 November 2005 05:45
To: EUforum
Cc: radhx at rediffmail.com
Subject: Re: Dynamic Menu Creation & Destroying them after each session

Rad wrote:
>Hi,
>
>I am trying to create dynamic menus/menuitems options for each log-in session.
Not /quite/ sure what you mean there. Log in or program run?
>Creating is fine, but destroying those menuitems is not going through.
>
>I tried to follow the logic destroyMenu in ARWEN, but could not get through.
As a convert to arwen, I may be able to help, though if you are in a
round about way asking how to apply what I consider that relatively
clear-cut logic to win32lib, now that I could never follow.
>Can not use both win32lib and arwen together because of namespace clashes.
True, plus two incompatible message loops from two GUI libs would be
more than a minor problem to get over.

My win32lib/MEditor project rebuilt menus, which seemed to work, but
to be honest was always problematical. See rebuildWindowMenu() in
file.e, which was as far as I got.

I have not re-attempted similar in arwen/Edita, though there is an
example shipped with arwen, demo_menus.exw which works just fine.

Regards,
Pete
PS MEditor (which I no longer support) and Edita are available from
http://palacebuilders.pwp.blueyonder.co.uk/euphoria.html
PPS As I am currently unable to post to Euforum, please cc any reply
both there and to me direct.
PPPS My recommendation is, of course, to dump win32lib and join the
growing arwen crowd!

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

Search



Quick Links

User menu

Not signed in.

Misc Menu