几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 09:16 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】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
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 08:54 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多