From: Mike Scholl on
I disable/enable menu items at runtime depending on user privileges.

I thought it might be easier to put the "Super User" tasks in a submenu so I
can disable them all by disabling the top item. but it doesn't seem to work

I tried both DeleteItem and DisableItem to no avail

Should I be adopting a different approach eg generate a new menu

Mike

In my Menu Init

SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_ID, ;
HyperLabel{#Utilities_Super_Tasks, ;
"Super Tasks", ;
, ;
,},GetSubMenu(SELF:Handle( ),4),20)
SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_Zap_Stables_ID, ;
HyperLabel{#ZapStables, ;
"Zap Stables", ;
"Delete all records from Stables file", ;
,})
SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_Zap_Payin_ID, ;
HyperLabel{#ZapPayin, ;
"Zap Payin", ;
"Delete all records from Payin file", ;
,})

METHOD SetMenuChoices CLASS C_ShowShellWindow
IF SELF:Menu == NULL_OBJECT
RETU
ENDIF
IF CMP_LOGON_LEVEL < SUPER_USER
SELF:Menu:DeleteItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_ID)



From: Kevin on
Mike,

I think you can only disable a parent menu item only if all the sub
menu items are disabled already. Cannot remember where I read I but I
that is the case.

Presumbly the users log in whwn the program starts? Can they switch
users without closing the program (assuming they know the login info)?
If not, is there any reason not to disable the items they should not
have access to?

Hope this helps.

Kevin

Mike Scholl wrote:

> I disable/enable menu items at runtime depending on user privileges.
>
> I thought it might be easier to put the "Super User" tasks in a
> submenu so I can disable them all by disabling the top item. but it
> doesn't seem to work
>
> I tried both DeleteItem and DisableItem to no avail
>
> Should I be adopting a different approach eg generate a new menu
>
> Mike
>
> In my Menu Init
>
> SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_ID, ;
> HyperLabel{#Utilities_Super_Tasks, ;
> "Super Tasks", ;
> , ;
> ,},GetSubMenu(SELF:Handle( ),4),20)
> SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_Zap_Stables_I
> D, ; HyperLabel{#ZapStables, ;
> "Zap Stables", ;
> "Delete all records from Stables file", ;
> ,})
> SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_Zap_Payin_ID,
> ; HyperLabel{#ZapPayin, ;
> "Zap Payin", ;
> "Delete all records from Payin file", ;
> ,})
>
> METHOD SetMenuChoices CLASS C_ShowShellWindow
> IF SELF:Menu == NULL_OBJECT
> RETU
> ENDIF
> IF CMP_LOGON_LEVEL < SUPER_USER
> SELF:Menu:DeleteItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_ID)



--

From: Harry B. on
Perhaps my sample could help: Look at "Downloads" on
http://www.voug-bodensee.net/ --> "DeleteSubMenu".

HTH,
Harry B.
From: Geoff Schaller on
Mike.

Disable works for me, but I use a variation of Marc Verkade's runtime
menu. Try disabling the menu item directly:

EnableMenuItem(SELF:Handle(), nItemID, _OR(MF_DISABLED, MF_GRAYED,
MF_BYCOMMAND))

The item can be a submenu.

Geoff



"Mike Scholl" <MikeScholl(a)btinternet.com> wrote in message
news:Ot2dncGLMsC0TRDVnZ2dnUVZ8vednZ2d(a)bt.com:

> I disable/enable menu items at runtime depending on user privileges.
>
> I thought it might be easier to put the "Super User" tasks in a submenu so I
> can disable them all by disabling the top item. but it doesn't seem to work
>
> I tried both DeleteItem and DisableItem to no avail
>
> Should I be adopting a different approach eg generate a new menu
>
> Mike
>
> In my Menu Init
>
> SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_ID, ;
> HyperLabel{#Utilities_Super_Tasks, ;
> "Super Tasks", ;
> , ;
> ,},GetSubMenu(SELF:Handle( ),4),20)
> SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_Zap_Stables_ID, ;
> HyperLabel{#ZapStables, ;
> "Zap Stables", ;
> "Delete all records from Stables file", ;
> ,})
> SELF:RegisterItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_Zap_Payin_ID, ;
> HyperLabel{#ZapPayin, ;
> "Zap Payin", ;
> "Delete all records from Payin file", ;
> ,})
>
> METHOD SetMenuChoices CLASS C_ShowShellWindow
> IF SELF:Menu == NULL_OBJECT
> RETU
> ENDIF
> IF CMP_LOGON_LEVEL < SUPER_USER
> SELF:Menu:DeleteItem(IDM_CS_ShellMenu_Utilities_Super_Tasks_ID)

From: richard.townsendrose on
Mike

here's a pile of stuff that Adriano developed for me years ago in VO1

most still in use today in 2.8sp1 !

richard

METHOD DeletePopup(nPos) CLASS Menu
// delete an item on main menu

DeleteMenu(SELF:Handle(), nPos-1, MF_BYPOSITION)

RETURN NIL
METHOD DeleteSubMenu(nParent, nPos) CLASS Menu
// delete item on submenu
LOCAL hPopup AS PTR
LOCAL lResult AS LOGIC

hPopup := GetSubMenu(SELF:Handle(), nParent-1) // rgtr 051107
removed 0 from handle call
lResult := DeleteMenu(hPopup, nPos-1, MF_BYPOSITION)

RETURN lResult
METHOD DisableAll() CLASS Menu
// called by Shell:MenuOff
LOCAL wCnt AS DWORD
LOCAL wPos AS DWORD

wCnt := DWORD(GetMenuItemCount(SELF:Handle(0)))
FOR wPos := 1 UPTO wCnt
EnableMenuItem(SELF:Handle(), wPos-1, MF_DISABLED+MF_BYPOSITION)
NEXT
ApplicationExec(EXECWHILEEVENT)

RETURN NIL
METHOD EnableAll() CLASS Menu
LOCAL wCnt AS DWORD
LOCAL wPos AS DWORD

wCnt := DWORD(GetMenuItemCount(SELF:Handle(0)))
FOR wPos := 1 UPTO wCnt
EnableMenuItem(SELF:Handle(),wPos-1,MF_ENABLED+MF_BYPOSITION)
NEXT
ApplicationExec(EXECWHILEEVENT)

RETURN NIL
TEXTBLOCK xx_NotUsed
/*
METHOD EnablePopup(nPos) CLASS Menu

EnableMenuItem(SELF:Handle(0),nPos-1,MF_ENABLED+MF_BYPOSITION)

RETURN NIL

METHOD DisablePopup(nPos) CLASS Menu

EnableMenuItem(SELF:Handle(0),nPos-1,MF_DISABLED+MF_BYPOSITION)

RETURN NIL

METHOD DisableMost() CLASS Menu
LOCAL wCnt AS DWORD // ARG121999 := 0 AS WORD
LOCAL wPos AS DWORD // ARG121999 WORD

wCnt := GetMenuItemCount(SELF:Handle(0))
FOR wPos := 2 UPTO wCnt
EnableMenuItem(SELF:Handle(0), wPos-1, MF_GRAYED+MF_BYPOSITION)
NEXT
ApplicationExec(EXECWHILEEVENT)

RETURN NIL

METHOD GrayAll() CLASS Menu
LOCAL wCnt AS DWORD
LOCAL wPos AS DWORD

wCnt := GetMenuItemCount(SELF:Handle(0))
FOR wPos := 1 UPTO wCnt
EnableMenuItem(SELF:Handle(0), wPos-1, MF_GRAYED+MF_BYPOSITION)
NEXT
ApplicationExec(EXECWHILEEVENT)

RETURN NIL
*/

 |  Next  |  Last
Pages: 1 2
Prev: WM_PASTE do not work everytime
Next: OleAutoObject