Sitemap

Amicuk Programming Answers

Unable to Delete a Menu.

2015-10-11   Views:0

Advertisement

Hi, I am having problems removing a menu (NNTP Newsgroup Actions). I can successfully delete all the menu items below this menu but then when I then try to delete the menu itself, using the Delete method of the GWMenu object, no error is raised but t

Hi,
I am having problems removing a menu (NNTP Newsgroup Actions).
I can successfully delete all the menu items below this menu but then when
I then try to delete the menu itself, using the Delete method of the
GWMenu object, no error is raised but the menu remains visible in the
client.
An overview of how my C3PO works:
- Read a text file containing the menu items to be removed. This is
performed during the Init function of the CommandFactory. A menu item is
specified by the full 'path' e.g. Actions|NNTP Newsgroup Actions|New
Discussion. The menu items are stored in a (globally declared) Scripting
dictionary object.
- In the CustomiseMenu function I call a procedure to iterate through the
menu items to be removed. Beginning with the top level menu object, the
code drills down the menu path identifying each menu level. If the menu
item is found, the menu type is determined (i.e. GWMenu or GWMenuAction)
and an appropriate object is instantiated and the Delete method called. I
have pasted the functions below.
- The CustomizeMenu function returns False so that the changes are not
volatile and applied the first time an instance of a context is created.
(Assume that the menus are removed regardless of the context.)
Can anyone suggest what I am doing wrong?
Many thanks in advance,
Andy
My environment:
GroupWise client version: 7.0.2 (6/4/2007)
Dev Language VB6 SP6
OS: Windows XP
Public Function CustomizeMenu(sGWContext As String, objGWMenu As Object)
As Boolean
'The changes are not volatile.
CustomizeMenu = False
'Remove the menu items listed in the global dictionary object:
gdicMenuItems.
Call UpdateLogFile("")
Call UpdateLogFile("")
Call
UpdateLogFile("*********************************** *************************************")
Call UpdateLogFile("*")
Call UpdateLogFile("* CustomizeMenu Called for Context: " & sGWContext)
Call UpdateLogFile("*")
Call
UpdateLogFile("*********************************** *************************************")
Call UpdateLogFile("")
Call RemoveMenus(objGWMenu)
End Function
Private Sub RemoveMenus(ByRef objTopMenu As Object)
'This procedure goes through the list of menu items stored in the global
dictionary object: gdicMenuItems
'and if they exist, the item is deleted.
'A typical entry in the dictionary object is "File|New|Document Version"
'The last component in the menu item path is the menu item that is deleted.
Dim objMenu As Object
Dim objGWMenuAction As C3POTypeLibrary.IGWMenuAction
Dim objGWMenu As C3POTypeLibrary.IGWMenu
Dim varFullMenuPath As Variant ' Menu path found in dictionary
object. e.g. "File|New|Document Version"
Dim strFullMenuPath As String ' The full menu path as a string.
Dim arrFullMenuPath() As String ' Menu path as an array, split by the
'|' character.
Dim strMenuItemName As String ' Menu path element e.g. File or New
or Document Version.
Dim lngMenuItemIdx As Long ' Loop index for drilling down the
menu path.
Dim blnMenuFound As Boolean ' Flag indicating whether the menu was
found.
Dim strMsgTxt As String ' Message box text.
On Error Resume Next
Call UpdateLogFile("RemoveMenus Procedure Started.")
Call UpdateLogFile("")
'Go through all the menus to be removed.
For Each varFullMenuPath In gdicMenuItems
'Convert the variant object representing the full menu path into a
string.
strFullMenuPath = CStr(varFullMenuPath)
Call UpdateLogFile("Strip the menu item: " & strFullMenuPath & ".")
'Split the menu into its component parts.
arrFullMenuPath = Split(CStr(varFullMenuPath), "|")
'Set the Menu object to represent the top level menu.
Set objMenu = objTopMenu
'Assume the menu can not be found.
blnMenuFound = False
'Drill down the menu path.
For lngMenuItemIdx = LBound(arrFullMenuPath) To UBound(arrFullMenuPath)
strMenuItemName = arrFullMenuPath(lngMenuItemIdx)
'Set the Menu item object to be the desired child menu item.
Set objMenu = objMenu.MenuItems.Item(strMenuItemName)
Select Case Err.Number
Case 0
' The child menu item was found.
Call UpdateLogFile(String(lngMenuItemIdx, vbTab) & "Found
menu item: '" & strMenuItemName & "'.")
blnMenuFound = True
Case 91
' The menu does not exist - therefore it does not have to
be removed.
Err.Clear
Call UpdateLogFile(" * Unable to find the menu item: '" &
strMenuItemName & "' as part of: " & strFullMenuPath & " in this context.")
blnMenuFound = False
Exit For
Case Else
strMsgTxt = "* An unexpected error was raised in the
'RemoveMenus' procedure when attempting to " & _
"instantiate an object representing a menu." &
vbCrLf & vbCrLf & _
"The full menu path was: " & strFullMenuPath & vbCrLf
& vbCrLf & _
"The menu item name was '" & strMenuItemName & "'." &
vbCrLf & vbCrLf & _
"The error number was " & Err.Number & " with the
description:" & _
vbCrLf & vbCrLf & Err.Description & vbCrLf & vbCrLf &
cstrHelp
Call UpdateLogFile(strMsgTxt)
MsgBox strMsgTxt, vbExclamation, cstrAppTitle
Err.Clear
blnMenuFound = False
Exit For
End Select
Next lngMenuItemIdx
'If the menu item was found, try to delete it.
If blnMenuFound = True Then
Call UpdateLogFile("Menu Identified: " & strFullMenuPath & ".
Caption: " & objMenu.Caption)
' If the menu has previously been stripped, the objMenu object may
be 'Nothing'.
' In this case, do not attempt to remove it.
Call UpdateLogFile("The menu type: " & TypeName(objMenu))
If TypeName(objMenu) = "Nothing" Then
Call UpdateLogFile("* The menu type is 'Nothing' therefore the
menu no longer exists in this context.")
Else
Call UpdateLogFile("Stripping the menu ...")
Select Case objMenu.ObjType
Case C3POTypeLibrary.GWOBJTYPE.eGW_GWMENUACTION
Set objGWMenuAction = objMenu
If Err.Number <> 0 Then
Call UpdateLogFile("* Failed to set a GW Menu
Action type object to this menu. Err Number: " & Err.Number)
Call UpdateLogFile(Err.Description)
Err.Clear
Else
objGWMenuAction.Delete
If Err.Number <> 0 Then
Call UpdateLogFile("* Failed to delete a GW
Menu Action type object. Err Number: " & Err.Number)
Call UpdateLogFile(Err.Description)
Err.Clear
Else
Call UpdateLogFile("Stripped the action menu
item: " & strFullMenuPath & ".")
End If
End If
Case C3POTypeLibrary.GWOBJTYPE.eGW_GWMENU
Set objGWMenu = objMenu
Call UpdateLogFile("The GW Menu has " &
objGWMenu.MenuItems.Count & " sub menu items.")
Call UpdateLogFile("The GW Menu Parent: " &
objGWMenu.Parent.Caption)
If Err.Number <> 0 Then
Call UpdateLogFile("* Failed to set a GW Menu type
object to this menu. Err Number: " & Err.Number)
Call UpdateLogFile(Err.Description)
Err.Clear
Else
objGWMenu.Delete
If Err.Number <> 0 Then
Call UpdateLogFile("* Failed to delete a GW
Menu type object. Err Number: " & Err.Number)
Call UpdateLogFile(Err.Description)
Err.Clear
Else
Call UpdateLogFile("Stripped the menu item: "
& strFullMenuPath & ".")
End If
End If
End Select
End If
End If
Next ' Next (full) menu path.
Set objMenu = Nothing
Set objGWMenuAction = Nothing
Set objGWMenu = Nothing
End Sub

The replay answer
Advertisement
Hi,
Novell informs me that the behaviour described below is normal. It is not
possible to delete any standard menu object (i.e. any client menu provided
by Novell). However, you can delete custom-made menus.
I think the documentation is misleading in that it states that we can not
delete 'root' menus. I understood this to be only the top level menus,
but this is not the case. We can not delete any standard client menu
which has child menu items regardless of their position in the menu
structure.
Thanks,
Andy
Andy Cooper wrote:
> Hi,
> I am having problems removing a menu (NNTP Newsgroup Actions).
> I can successfully delete all the menu items below this menu but then when
> I then try to delete the menu itself, using the Delete method of the
> GWMenu object, no error is raised but the menu remains visible in the
> client.
> An overview of how my C3PO works:
> - Read a text file containing the menu items to be removed. This is
> performed during the Init function of the CommandFactory. A menu item is
> specified by the full 'path' e.g. Actions|NNTP Newsgroup Actions|New
> Discussion. The menu items are stored in a (globally declared) Scripting
> dictionary object.
> - In the CustomiseMenu function I call a procedure to iterate through the
> menu items to be removed. Beginning with the top level menu object, the
> code drills down the menu path identifying each menu level. If the menu
> item is found, the menu type is determined (i.e. GWMenu or GWMenuAction)
> and an appropriate object is instantiated and the Delete method called. I
> have pasted the functions below.
> - The CustomizeMenu function returns False so that the changes are not
> volatile and applied the first time an instance of a context is created.
> (Assume that the menus are removed regardless of the context.)
> Can anyone suggest what I am doing wrong?
> Many thanks in advance,
> Andy
> My environment:
> GroupWise client version: 7.0.2 (6/4/2007)
> Dev Language VB6 SP6
> OS: Windows XP
> Public Function CustomizeMenu(sGWContext As String, objGWMenu As Object)
> As Boolean
> '
> 'The changes are not volatile.
> CustomizeMenu = False
> '
> 'Remove the menu items listed in the global dictionary object:
> gdicMenuItems.
> Call UpdateLogFile("")
> Call UpdateLogFile("")
> Call
>
UpdateLogFile("*********************************** *************************************")
> Call UpdateLogFile("*")
> Call UpdateLogFile("* CustomizeMenu Called for Context: " & sGWContext)
> Call UpdateLogFile("*")
> Call
>
UpdateLogFile("*********************************** *************************************")
> Call UpdateLogFile("")
> '
> Call RemoveMenus(objGWMenu)
> '
> End Function
> Private Sub RemoveMenus(ByRef objTopMenu As Object)
> '
> 'This procedure goes through the list of menu items stored in the global
> dictionary object: gdicMenuItems
> 'and if they exist, the item is deleted.
> '
> 'A typical entry in the dictionary object is "File|New|Document Version"
> '
> 'The last component in the menu item path is the menu item that is deleted.
> '
> Dim objMenu As Object
> Dim objGWMenuAction As C3POTypeLibrary.IGWMenuAction
> Dim objGWMenu As C3POTypeLibrary.IGWMenu
> Dim varFullMenuPath As Variant ' Menu path found in dictionary
> object. e.g. "File|New|Document Version"
> Dim strFullMenuPath As String ' The full menu path as a string.
> Dim arrFullMenuPath() As String ' Menu path as an array, split by the
> '|' character.
> Dim strMenuItemName As String ' Menu path element e.g. File or New
> or Document Version.
> Dim lngMenuItemIdx As Long ' Loop index for drilling down the
> menu path.
> Dim blnMenuFound As Boolean ' Flag indicating whether the menu was
> found.
> Dim strMsgTxt As String ' Message box text.
> '
> On Error Resume Next
> '
> Call UpdateLogFile("RemoveMenus Procedure Started.")
> Call UpdateLogFile("")
> '
> 'Go through all the menus to be removed.
> For Each varFullMenuPath In gdicMenuItems
> '
> 'Convert the variant object representing the full menu path into a
> string.
> strFullMenuPath = CStr(varFullMenuPath)
> Call UpdateLogFile("Strip the menu item: " & strFullMenuPath & ".")
> 'Split the menu into its component parts.
> arrFullMenuPath = Split(CStr(varFullMenuPath), "|")
> '
> 'Set the Menu object to represent the top level menu.
> Set objMenu = objTopMenu
> '
> 'Assume the menu can not be found.
> blnMenuFound = False
> '
> 'Drill down the menu path.
> For lngMenuItemIdx = LBound(arrFullMenuPath) To UBound(arrFullMenuPath)
> strMenuItemName = arrFullMenuPath(lngMenuItemIdx)
> 'Set the Menu item object to be the desired child menu item.
> Set objMenu = objMenu.MenuItems.Item(strMenuItemName)
> Select Case Err.Number
> Case 0
> ' The child menu item was found.
> Call UpdateLogFile(String(lngMenuItemIdx, vbTab) & "Found
> menu item: '" & strMenuItemName & "'.")
> blnMenuFound = True
> Case 91
> ' The menu does not exist - therefore it does not have to
> be removed.
> Err.Clear
> Call UpdateLogFile(" * Unable to find the menu item: '" &
> strMenuItemName & "' as part of: " & strFullMenuPath & " in this context.")
> blnMenuFound = False
> Exit For
> Case Else
> strMsgTxt = "* An unexpected error was raised in the
> 'RemoveMenus' procedure when attempting to " & _
> "instantiate an object representing a menu." &
> vbCrLf & vbCrLf & _
> "The full menu path was: " & strFullMenuPath & vbCrLf
> & vbCrLf & _
> "The menu item name was '" & strMenuItemName & "'." &
> vbCrLf & vbCrLf & _
> "The error number was " & Err.Number & " with the
> description:" & _
> vbCrLf & vbCrLf & Err.Description & vbCrLf & vbCrLf &
> cstrHelp
> Call UpdateLogFile(strMsgTxt)
> MsgBox strMsgTxt, vbExclamation, cstrAppTitle
> Err.Clear
> blnMenuFound = False
> Exit For
> End Select
> Next lngMenuItemIdx
> '
> 'If the menu item was found, try to delete it.
> If blnMenuFound = True Then
> Call UpdateLogFile("Menu Identified: " & strFullMenuPath & ".
> Caption: " & objMenu.Caption)
> ' If the menu has previously been stripped, the objMenu object may
> be 'Nothing'.
> ' In this case, do not attempt to remove it.
> Call UpdateLogFile("The menu type: " & TypeName(objMenu))
> If TypeName(objMenu) = "Nothing" Then
> Call UpdateLogFile("* The menu type is 'Nothing' therefore the
> menu no longer exists in this context.")
> Else
> Call UpdateLogFile("Stripping the menu ...")
> Select Case objMenu.ObjType
> Case C3POTypeLibrary.GWOBJTYPE.eGW_GWMENUACTION
> Set objGWMenuAction = objMenu
> If Err.Number <> 0 Then
> Call UpdateLogFile("* Failed to set a GW Menu
> Action type object to this menu. Err Number: " & Err.Number)
> Call UpdateLogFile(Err.Description)
> Err.Clear
> Else
> objGWMenuAction.Delete
> If Err.Number <> 0 Then
> Call UpdateLogFile("* Failed to delete a GW
> Menu Action type object. Err Number: " & Err.Number)
> Call UpdateLogFile(Err.Description)
> Err.Clear
> Else
> Call UpdateLogFile("Stripped the action menu
> item: " & strFullMenuPath & ".")
> End If
> End If
> Case C3POTypeLibrary.GWOBJTYPE.eGW_GWMENU
> Set objGWMenu = objMenu
> Call UpdateLogFile("The GW Menu has " &
> objGWMenu.MenuItems.Count & " sub menu items.")
> Call UpdateLogFile("The GW Menu Parent: " &
> objGWMenu.Parent.Caption)
> If Err.Number <> 0 Then
> Call UpdateLogFile("* Failed to set a GW Menu type
> object to this menu. Err Number: " & Err.Number)
> Call UpdateLogFile(Err.Description)
> Err.Clear
> Else
> objGWMenu.Delete
> If Err.Number <> 0 Then
> Call UpdateLogFile("* Failed to delete a GW
> Menu type object. Err Number: " & Err.Number)
> Call UpdateLogFile(Err.Description)
> Err.Clear
> Else
> Call UpdateLogFile("Stripped the menu item: "
> & strFullMenuPath & ".")
> End If
> End If
> End Select
> End If
> End If
> '
> Next ' Next (full) menu path.
> '
> Set objMenu = Nothing
> Set objGWMenuAction = Nothing
> Set objGWMenu = Nothing
> '
> End Sub

Go to See the other 5 answers

Unable to Delete a Menu.

Category:DefaultRelease time:2015-10-11Views:130

Hi, I am having problems removing a menu (NNTP Newsgroup Actions). I can successfully delete all the menu items below this menu but then when I then try to delete the menu itself, using the Delete method of the GWMenu object, no error is raised but t[More]

Unable to delete items from recycle bin

Category:DefaultRelease time:2015-10-11Views:130

Unable to delete items from my trash, it starts to delete then stops along the way, when i open the trash, its still sat there.Relaunch the Finder, then from the Finder menu bar, select Finder ▹ Preferences ▹ Advanced and uncheck the box marked Empty[More]

My phone has been restored using iTunes.  All of my previous photo are not downloaded on my phone and I'm unable t delete - no trash bin.

Category:DefaultRelease time:2015-10-11Views:130

My phone has been restored using iTunes.  All of my previous photo are downloaded. I'm unable to delete the photos from the phone - no trash bin.  It has utilized all my storage and I'm unable to use any of my apps.Hello there, Jeanne2919. There is a[More]

Unable to delete saved Crystal reports in SAP BW Browser

Category:DefaultRelease time:2015-10-11Views:130

Hi everyone , We are trying to test Integration of Crystal reports with SAP BW . CR developer version installed - 12.0.3.900 SAP BW 7.0 I have 2 issues : 1) When I try to open SAP Query from CR SAP menu bar , somehow a blank SAP screen opens first an[More]

Hot
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.sql.*; public class LoginServletJDBC extends HttpServlet{      public void doGet(HttpServletRequest request,HttpServletResponse response)      throws ServletException, [More]
A unknown album showed up out of nowhere in my pictures and contains "blank" pictures that look greyish and when you click on one it comes up black with no options like a normal picture. I've tried deleting the pictures individually and as an al [More]
My company uses Citrix Receiver to provide remote access to some LOB applications and network resources. I understand it to be a popular system in that market.  Every time I use it, however, it drives me nuts by changing the visual settings on my com [More]
Hello Professional Sun Users, According to: http://blogs.sun.com/meena/entry/disabling_trace_in_sun_java I can disable HTTP TRACE by either through: 1. Adding the following code into obj.conf <Client method="TRACE"> AuthTrans fn="set- [More]
Here are some key features of Blackberry Z10 and Q10: 1) The Z10 which has a 4.2-inch screen(1,280 x 768 display), will be sold at an unsubsidized price of $599, but can be obtained through some carriers for $149 with a three-year contract. Pricing f [More]
I'm developing app that will allow the customers to store their data in azure. However, currently I have no idea how to split  accounts of the customers in azure. Yes, I'm just started to read the documentation, but maybe someone can point me to the [More]
So, I've had my iPhone 5 for a little over a year now and just yesterday went out and bought my first Mac.  When I got my phone I didn't anticipate getting a Mac and thus used my gmail account as my Apple ID.  I was advised by a friend of mine that e [More]
In Snow Leopard I would drag invitees to an event from Address Book and it would begin checking their availability.  Now when I drag an invitee, the red bubble with the number of contacts I'm dragging over appears, but the invitees don't actually mak [More]
This error message comes up everytime I try to upload photos onto my ipod. I selected the folder to sync the photos from and I do not know why it will not upload. Does anyone know what to do?Alexander, I did what you suggested. In fact, this is what [More]
Any ideas on how i can resolve and get back to playing my purchased films in itunes ThanksHi jinjoe, I am sorry for the issues you are experiencing with your upgrade. How is this memory installed? Is it just one module or did you purchase two? Did yo [More]