How to Add a ContextMenu for ActiveX TreeView

Hello, guys
I have used GUIDE to generate a GUI, and Create a TreeView by MSComctlLib.TreeCtrl.2.
The problem is I don't know how to Add a ContextMenu for the TreeView. I have added a ContextMenu for the Tree as the following Codes, but which is not working properly.
Could anybody help me to work out the problem? Thank you!
Kind regard,
Keming
function click_node(varargin)
event=varargin{end};
switch event
case 'MouseUp'
if varargin{3}==2
f=gcf;
uc=uicontextmenu('parent',f);
set(h,'units','pixels');
pl=get(0,'pointerlocation');
fp=get(h,'position');
fp = fp(1:2);
u1=uimenu(uc,'label','New','callback','disp(''New'')');
u2=uimenu(uc,'label','Load','callback','disp(''Load'')');
u3=uimenu(uc,'label','Delete','callback','disp(''Delete'')');
set(uc,'position',pl-fp,'visible','on');
end
end

回答 (1 件)

Steve Coleman
Steve Coleman 2012 年 12 月 28 日

0 投票

1 件のコメント

Keming
Keming 2013 年 1 月 4 日
Hi,Steve, Thanks for your comments. I am current focusing on using ActiveX Control. Right now, I am able to add a contextmenu to ActiveX tree object, but I dont know how to popup a context menu when the user right click the tree node.

サインインしてコメントする。

質問済み:

2012 年 12 月 21 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by