![]() |
【转帖】how to find the position of a menu item
how to find the position of a menu item?
hello, i am trying to use the addmenuitem() function to add a menu item just above the "print" menu item in the "file" menu dropdown. the function needs a position which specifies where the menu item is to be inserted. i will need a different value for position for each version of solidworks and its document types (part, assembly, drawing). moreover, if another add-in had added a menu item in the "file" menu, my menu will be misplaced. is there a way wherein i can get the position of the file->print menu item and then pass it to the function so that my menu item always appears before the "print" menu item? i looked around the api help file but could not find a function. regards, deelip menezes deelip menezes how have you added the item to the file menu in the first place? yes, i have. deelip menezes deelip menezes "how" have you added it... code. if i can see your method i can help you better code in vc 6 add-in for solidworks 2007 & earlier ================================ m_psldworks->addmenuitem(swdocpart, _t("mymenuitem@&file"), 17, _t("mydll@mycallbackfunction@,my message"), &retval); code in vc 2005 add-in for solidworks 2008 ============================= iswapp->addmenuitem3(swdocpart, addinid, _t("mymenuitem@&file"), 16, _t("mycallbackfunction"), null, _t("my message"), _t("mainiconsmall.bmp"), &bres); deelip menezes update (16-may-2008) =============== someone from solidworks api support got back to me saying that as far as he knew there isn't any api to find a menu item. deelip menezes deelip, i'm sure there is a way. i will have a play this weekend for you and let you know what i find. i can get the main frame menu, and then search in the menu tree. but then i come across the problem of language. it may work for the english version of solidworks, and i would have to add code to handle other languages. obviously this is not the approach i want to take, even as a last resort. let me know what you find. looking forward to reading your book. deelip menezes hi deelip i think this macro might help dim swapp as sldworks.sldworks dim oframe as sldworks.frame dim l_submenucount as long dim vsubmenues as variant sub main() dim bretval as boolean set swapp = application.sldworks set oframe = swapp.frame l_submenucount = oframe.getsubmenucount(swdocdrawing, "&file") vsubmenues = oframe.getsubmenus(swdocdrawing, "&file") ' vsubmenues holdes the name and position of every menu ite, in the file menu dim i as integer for i = 0 to l_submenucount - 1 debug.print cstr(i) & " " & vsubmenues(i) next i end sub ' here is the output 0 &new... 1 &open... 2 &close 3 4 &save 5 save &as... 6 save sheet forma&t... 7 sav&e all 8 9 &find references... 10 11 pa&ge setup... 12 print pre&view... 13 change file description 14 &print... 15 16 pac&k and go... 17 sen&d to... 18 propert&ies... 19 20 r&ecent file 21 22 e&xit 23 sdw to teamcenter 24 convertor i hope this helps regards dudi peer eci telecom quick |
所有的时间均为北京时间。 现在的时间是 04:14 PM. |