|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- <p><div class="blockcode"><blockquote>
. ?; |8 U. X6 \( a& R! u - . K: _9 K' |1 c9 u7 r
3 ]! a) p% M! J) _- enum MenuID
, r" A2 i4 k1 C- n: p3 ~ - {
3 \2 b6 z3 z% R1 e - RemovetopNode = 0,
, h! [! R) H6 x* t- [; N) y( a! ] - DeleteNode,
) k0 `' i9 K9 B6 A6 B - CheckedMenuItem,4 [4 b: J8 C) h0 e: J0 U
- DefaultMenuItem,
- x: J. D) H/ ~7 ] - DialogLaunchMenuItem,
9 i- ]: C6 F* t1 T2 { {$ a - DisableMenuItem,
1 d$ H* X# U* H' G4 `, [ - HiddenMenuItem,
' { R; ^3 U& ~- s. ` - IconMenuItem,
" Z* f# n/ T3 y
. V$ X; p; D4 n/ o# N1 d- SubMenuItem1,
2 I0 Y0 d9 q$ x6 n+ P - SubMenuItem2,: q. v; I/ F& q5 u
- SubMenuItem3,
5 S+ @5 E" r0 ~3 |- V6 _/ W2 D - SubMenuItem4,- Q3 }; N/ ~" u9 t( N- v
7 U/ R6 W x# [- historymenu,0 o+ Z1 K0 E" F7 g1 W/ m
- nohistorymenu,
- |/ U# l* ~& n' d. W
! U: \+ O; q/ }6 a% E" d- modelhistoryfilter,
7 v0 C# g; d+ q$ i - filterSubMenuItem1,
5 z! d9 w2 o: l8 z! j8 l - filterSubMenuItem2,' H' a. z2 m$ W5 c* y
! R1 ^, }4 t2 K* K o$ `- 8 C( q# B8 Z3 P: X3 F9 M4 y
- };
( q6 p8 P/ e: ?6 `4 V! t - void tree::OnMenuCallback(NXOpen::BlockStyler::Tree *tree, NXOpen::BlockStyler::Node *node, int columnID )% @5 H" o4 }2 Q. B/ n
- {
% D$ {% d- v; q - TreeListMenu *menu= tree->CreateMenu();3 k# |% w8 s% @: ~" b
- TreeListMenu *submenu = tree->CreateMenu();) d- Z" k% h* k+ a
- if(node==NULL)
- @7 @3 C- W5 y5 A( N' r, W4 h - {
( H. A, B6 d" K- Y/ i- g" w5 H. f9 i - menu->AddMenuItem(RemovetopNode,"Remove Top Node","delete");; j5 b& v# t# P, a" k
- menu->AddMenuItem(CheckedMenuItem,"Checked Menu Item");# q7 }# f) |) b' B u
- menu->AddMenuItem(DefaultMenuItem,"Default Menu Item");
+ z% s# R" T, G5 {) E; [6 N- i - menu->AddSeperator();) `4 H( T- T5 n( w/ h3 j( T
- menu->AddMenuItem(DialogLaunchMenuItem,"DialogLaunchMenuItem");5 l3 H. z8 X; P4 z4 A
- menu->AddMenuItem(DisableMenuItem,"DisableMenuItem");1 o: a' `" e) |1 d. [' T. O+ T
- menu->AddMenuItem(HiddenMenuItem,"HiddenMenuItem");
" K7 i+ }8 ?$ j' L; h9 ^ - menu->AddMenuItem(IconMenuItem,"IconMenuItem");! A1 G9 J0 n$ J, Q6 o1 Q
- : {$ y. ?7 a7 M& _. B
- menu->SetItemDefault(DefaultMenuItem,true);0 u* x2 W _, Y- W; c- s- ]: x# D" u
- menu->SetItemChecked(CheckedMenuItem,true);' N: {$ `* ^4 V: W6 V7 S
- menu->SetItemDialogLaunching(DialogLaunchMenuItem,true);1 C8 N3 j. K. y z
- menu->SetItemDisable(DisableMenuItem,true);
5 Z8 V3 @. x4 P. J) h4 T* [) i - menu->SetItemHidden(HiddenMenuItem,true);
9 p2 C( `( Y% H! m* T/ t4 w- ^( g - menu->SetItemIcon(IconMenuItem,"skeTCh");
" ^! u) k/ |! f- V8 k; O1 X - menu->SetItemText(RemovetopNode,"Remove Top Nodes");3 X7 u7 g C- I; J. |
1 L% e- b b0 x4 H; Y- // submenu, c9 q8 E3 u: Z3 _1 U
- submenu->AddMenuItem( SubMenuItem1,"Model Views");% l. b: |9 Q/ n, Z/ y9 V' x8 E: i* v
- submenu->AddMenuItem( SubMenuItem2,"Cameras");
5 F/ b- g, F3 \* U% C8 x: R# z - submenu->AddMenuItem( SubMenuItem3,"Model History");- q. y1 m: ^. g5 E
- submenu->AddMenuItem( SubMenuItem4,"History Model");5 s9 Y, c2 L8 D/ n+ M8 p
- " C2 z* \) g% C$ q$ [9 E% W
- menu->SetSubMenu(RemovetopNode,submenu);; ^/ ~ L U( E0 ]# r6 }" v
$ I* ?9 t; |" e% b q* s- }
- E/ [0 o1 Z \( ~" o1 k - else
' ?+ P/ t- U6 a, w7 X - {2 Y; T4 e* N- p; V
- if(node==modelhistoryNode)( t$ y7 i: N+ k. J
: m X/ U& w3 P `3 `1 l% y- {* W; E5 T1 }7 c0 O2 z
- menu->AddMenuItem(modelhistoryfilter,"Filter");
) }7 I0 b, K2 b8 T* u9 q6 r& d3 F - // submenu- K- i) U0 f2 F& T: k! ^" o
- submenu->AddMenuItem( filterSubMenuItem1,"Remove Item");
& J' W; X6 E# l* s4 v1 m - submenu->AddMenuItem( filterSubMenuItem2,"Remove All But Item");( K6 F. I" u/ b" E4 D$ ]4 g
- menu->SetSubMenu(modelhistoryfilter,submenu);
6 L/ h y# c4 ?2 d: S - }1 y3 a, j# \) {3 L3 t' \
- else if (node==historyModeNode)
" j7 }$ f3 v, x! t6 {: ?5 q - {
+ t* e1 r% z3 y, l. Q) [/ |- X - menu->AddMenuItem(historymenu,"History Mode");
5 J& A1 f* B) d* `, v% v- c, K+ { - menu->AddMenuItem(nohistorymenu,"History-Free Mode");
Q2 G) k: t& E2 X1 h0 k - menu->SetItemIcon(historymenu,"check");2 C- J6 h+ m2 A0 L
- }
1 N, D! t1 W" T8 g6 N( W" R- Q
6 }* U$ c# D' j. q/ S/ z- }
) _/ s# _$ X. e; W. Q
6 L: }/ H6 g1 Q2 b Z" S- tree_control0->SetMenu(menu); f; n) N0 @: \ n! D
- # g$ G+ ^; v( e$ ~" p; M
- delete menu;
1 K( r/ b* l3 ` e t0 m7 U - delete submenu;, [& ^( d! |' L9 K( i1 B
- }
4 X7 m+ Q; S3 O( u8 o& B! E
复制代码
1 {8 K* d( h E. P( j, b6 Y) s6 D2 Q, e) i: {0 ~0 H
; { y1 K6 d% ]8 k* ]NX二次开发treelist控件添加右键快捷菜单回调函数的简单例子
* R9 j$ t- \3 S$ b( B% @
[1 Y0 H, k. t/ \7 T- x8 y% p$ B+ O这里大概的模拟了下 部件导航器的功能!+ H4 M& ^9 I8 N) T/ p5 ~
% |5 R8 C6 v$ ~/ J) ]1 l7 ~3 G* h4 T5 o. S
NX二次开发treelist控件
5 V( V# V) l( g% C2 V! o: j: R; A0 a/ @" D) F
NX二次开发treelist控件
' H, V6 U; Q* C+ a) j# p
# z4 F. @2 |. z& R2 J
NX二次开发treelist控件
. Y! N; m) ~/ C b* D( U; p E6 K F; g
/ `0 B5 @3 ]- y- Q- x8 h/ l |
|