[VBA - active X] Identifying a shortcut menu

I'm trying to modify the POP502 popupmenu
and only that one.
I've found some code one Afralisp site, and on Autocad 2000 VBA
programmation manual
But i don't find solution to clearely identify which popup is my
"command edition contextual menu" (the pop502 one)
I don't want to modify the POP0 one.
The other problem is that the POP502 don't have the Shortcutmenu = True
until the user has activate it one time !!
Is there is someone that now how to get the "label" or "Alias"
(POP502.CMEDIT) of a popupmenu ?
Thanks a lot
Gérald Lemoine
I place there the code that i've made:
It works, but i'me never shure of the menu i modify !
;§/menu/add an item to a contextual menu/pos StrItem StrMacro AddSeparator
;;pos = integer for Menuitem position. Pos = 0 ad ythe beginning
;;StrItem = string label of item
;;StrMacro = String macro associated to item
;;Addseparator nil : none , T : before & after , 1 after , 0 before
(defun pw_addItem2ContextualMenu ( pos StrItem StrMacro AddSeparator /
ok i j acadObject AcadMenuGroup NbMenuGroup currMenuGroup
currMenuGroupMenus scMenu AlreadyExist)
;;sous-commande pour tester la pré-existance de l'entrée de menu
(defun AlreadyExist (popMenu label /
k nb Oui ssMenu)
(setq nb (vlax-get-property popMenu 'Count))
;;parcours le menus pour trouver le même label
(setq k 0)
(while (and (< k nb) (not oui))
(setq ssMenu (vlax-invoke-method popMenu 'Item k ))
;;(vlax-invoke-method id 'Delete )
(if (= label (vlax-get-property ssMenu 'label))
(setq Oui T )
(setq k (+ 1 k))
(setq acadObject (vlax-get-acad-object))
(setq AcadMenuGroup (vla-get-MenuGroups acadObject))
(setq NbMenuGroup (vlax-get-property AcadMenuGroup 'Count))
(setq j 0)
(while (and (< j NbMenuGroup) (not ok))
(setq currMenuGroup (vlax-invoke-method AcadMenuGroup 'Item j ))
(setq currMenuGroupMenus (vla-get-Menus currMenuGroup))
(setq nb (vlax-get-property currMenuGroupMenus 'Count))
;;parcours les menus pour trouver celui qui est contextuel
(setq i 0)
(while (and (< i nb) (not ok))
(setq scMenu (vlax-invoke-method currMenuGroupMenus 'Item i ))
(if (= ':VLAX-TRUE (vlax-get-property scMenu 'ShortcutMenu))
(setq ok T )
(setq i (+ 1 i))
(setq j (+ 1 j))
(if ok
(prompt "\nFinded contextual menu")
;;verifie si item n'existe pas, et ajoute l'item
(if (not (AlreadyExist scMenu StrItem))
scMenu 'AddMenuItem pos StrItem StrMacro)
((= Addseparator T)
(vlax-invoke-method scMenu 'AddSeparator pos)
(vlax-invoke-method scMenu 'AddSeparator (+ pos 1))
((= Addseparator 1)
(vlax-invoke-method scMenu 'AddSeparator (+ pos 1))
((= Addseparator 0)
(vlax-invoke-method scMenu 'AddSeparator pos)
;;(vlax-method-applicable-p currMenuGroup 'Save )
(vlax-invoke-method currMenuGroup 'Save acMenuFileCompiled)
(prompt (Strcat "\n" StrItem " item added to contextual
(Strcat "\n" StrItem " already exist in contextual menu")
(prompt "\nUnable to Find contextual menu")
Reply to
Loading thread data ...
Check for the desired shortcut menu's name in place of this: (if (= ':VLAX-TRUE (vlax-get-property scMenu 'ShortcutMenu))
use this (if (eq (vlax-get-property scMenu 'NameNoMnemonic) "command edition contextual menu");;make sure to use the POP502's name
HTH, Jeff
Reply to
Jeff a écrit :
Jeff, I initially thought to use a similar solution, but for me it's a little dangerous : It is designed to install an application on Worlwide Autocad localisation version. So the 'NameNoMnemonic property cannot be used very safely. I can't explain that a so significant information, the identifiant, cannot be accessed. The 'Tagstring vary from a session to another, so it cannot be used.
Something i can do is to ask on this forum for the name of their command menu edition : In German in Italian, in Spanish ... even in Korean ...
But it is still dangerous, because user can have changed this name. so initially, the shortcutproperty was very interresting, but it's not working
Thanks, Gérald
PowerClic :
formatting link
Reply to

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.