Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic System Architect (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 20-Nov-2007 11:08
User is offline View Users Profile Print this message


Toby Chaloner

Posts: 29
Joined: 22-Aug-2007

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
Report this to a Moderator Report this to a Moderator
 1-Dec-2007 01:05
User is offline View Users Profile Print this message


Nancy Coelho

Posts: 8
Joined: 13-Jun-2007

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?
Report this to a Moderator Report this to a Moderator
 18-Jul-2008 11:55
User is offline View Users Profile Print this message


Arif Hussain

Posts: 53
Joined: 22-Dec-2005

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.
Report this to a Moderator Report this to a Moderator
 18-Jul-2008 15:39
User is offline View Users Profile Print this message


Peter Crabb-Wyke

Posts: 73
Joined: 3-May-2007

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)
Report this to a Moderator Report this to a Moderator
 18-Jul-2008 15:39
User is offline View Users Profile Print this message


Peter Crabb-Wyke

Posts: 73
Joined: 3-May-2007

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
Report this to a Moderator Report this to a Moderator
 23-Jul-2008 12:36
User is offline View Users Profile Print this message


Toby Chaloner

Posts: 29
Joined: 22-Aug-2007

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

Report this to a Moderator Report this to a Moderator
 23-Sep-2008 16:52
User is offline View Users Profile Print this message


Arif Hussain

Posts: 53
Joined: 22-Dec-2005

Phew.... that's a relief.

Telelogic doctors have confirmed that I may not be paranoid.

Telelogic Support and development have confirmed that:
    they are unable to control the order of menu inserted using InsertMacroItemInMenu

    the SetSeparatorBefore function does not work


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(), method will totally remove the popup from the menu system."

I tried it and managed to put the menu items in order.
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic System Architect forum.
There are currently 1 users logged in.
The most users ever online was 16 on 30-Oct-2008 at 14:46.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.