几何尺寸与公差论坛

 找回密码
 注册
查看: 951|回复: 0

【转帖】how to find the position of a menu item

[复制链接]
发表于 2009-4-12 21:16:50 | 显示全部楼层 |阅读模式
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 13:01 , Processed in 0.036394 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表