![]() |
Telelogic System Architect (steve huntington) | ![]() |
Topic Title: Unexpected behaviour when adding a popup menu? Topic Summary: The Popup is created, but item attaches to wrong menu Created On: 20-Nov-2007 11:08 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Can anyone correct my attempt to create a popup menu. The following VBA code adds a popup menu to the Tools menu. But the item I try and add to the new menu is attached to the Tools menu instead.
I want to achieve a menu hierachy that looks like: Tools->MyPopupMenu->TestMenuItem This attempts to be close to the illustration in the VBA manual (v10.7 p15-13) ''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub TestMenuPopup() MsgBox "Hello" End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub testInteractiveMenusSetup() Dim app As Application Set app = New SA2001.Application Dim x As Long Dim s As String 'these functions return 0 on success x = app.CreatePopUpMenu("MyPopupMenu") Debug.Assert 0 = x s = "SystemArchitectDevelopment." 'my VBA Project name s = s & "MiscTasks." 'my module name s = s & "TestMenuPopup" 'the sub to run Dim menuItem As String menuItem = "TestMenuItem" x = app.InsertMacroItemInMenu(s, menuItem, "MyPopupMenu") Debug.Assert 0 = x x = app.InsertPopupMenuItemInMenu("MyPopupMenu", "&Tools") Debug.Assert 0 = x x = app.EnableMenu("MyPopupMenu", True) Debug.Assert 0 = x x = app.SetSeparatorBefore("MyPopupMenu", "&Tools", True) Debug.Assert 0 = x End Sub |
|
![]() |
|
![]() |
|
Iwant to extend the SA menu's too. I'm trying to build a VB ActiveX dll. How does the SA know about this dll and how to tell the SA to load your dll. Does it have to be in a specific location?
|
|
![]() |
|
![]() |
|
Been having fun with a similar menu problem.
![]() One of the sub-items appeared at the higher level aswell as the lower level. I interchanged the menu items and still it was the same culpirt. In the end I changed the module name to make it work. ![]() Also tried changing the function name. Renamed both back to original and it works OK. ![]() Still unable to insert any popup menu in correct place. Still unable to order my own menu items in desired order. Insists on putting it in alphabetical function name order. Still unable to add any separators. Other than that, it works. ![]() Tried Toby's example to bring me back to sanity and it works as desired. Hard to explain these inconsistencies other than some one pressing the "don't work" switch. |
|
![]() |
|
![]() |
|
I have always created and inserted the pop-up menu before adding any macros to it. That has always seemed to work.
On the other hand I might just have been lucky and nobody else here knows about the "don't work" switch (aka the paranoia generator - a well known feature of most IT systems) |
|
![]() |
|
![]() |
|
oops - no response so I hit enter again.
The paranoia generator is doing its job here! Edited: 18-Jul-2008 at 15:41 by Peter Crabb-Wyke |
|
![]() |
|
![]() |
|
Peter
Thanks a bunch, I modified my example to the code below and it worked! Beware of the gotcha I have documented. ''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub TestMenuPopup() MsgBox "Phew" End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''' 'trying suggestion of adding menu to target 'prior to filling it ' 'The following code works for me. 'BUT The path to the macro to be called must start ' with the name of you macro file!!! ''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub testInteractiveMenusSetup() Dim app As Application Set app = New SA2001.Application Dim x As Long Dim s As String '################################# ' The name below must be the name ' of your macro file '################################# s = "TobySystemArchitectMacros." 'my VBA Project name s = s & "MiscTasks." 'my module name s = s & "TestMenuPopup" 'the sub to run Dim menuItem As String menuItem = "TestMenuItem" 'these functions return 0 on success x = app.CreatePopUpMenu("MyPopupMenu") Debug.Assert 0 = x x = app.InsertPopupMenuItemInMenu("MyPopupMenu", "&Tools") Debug.Assert 0 = x x = app.InsertMacroItemInMenu(s, menuItem, "MyPopupMenu") Debug.Assert 0 = x x = app.EnableMenu("MyPopupMenu", True) Debug.Assert 0 = x 'x = app.SetSeparatorBefore("MyPopupMenu", "&Tools", True) 'Debug.Assert 0 = x End Sub |
|
![]() |
|
![]() |
|
Phew.... that's a relief.
![]() Telelogic doctors have confirmed that I may not be paranoid. Telelogic Support and development have confirmed that:
It appears SA does have a "don't work" switch. But after coming across: "Since all popups and tools which are added to the menu system will remain even after SA has been restarted, it may become necessary to remove a popup menu which is no longer required. The App.RemovePopUpMenu( I tried it and managed to put the menu items in order. |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.