原帖由 shwwd 于 2007-6-20 13:51 发表
‘关于 GUI 心得’已经读了,不过还是不能实现我想实现的一下功能:
菜单File-New中想另打开一个本GUI程序,callback中该怎样实现?
菜单Help-Help,想打开一个文件(格式可能为.htm .doc .pdf),callbac ...
四个问题的解答:
1. help eval
2. help winopen
3. 参考以下代码:-
- 'CallBack','[x, maps] = imread(''logo.bmp'');msgbox({''Version 1.0'';'' '';''December 16, 2006'';'' '';''Copyright 2006''},''About ABC'',''custom'', x, maps,''modal'')'
复制代码 4. 使用以下函数:(注:请勿用作商业用途,否则 matlab 有权举报侵权。特别留意函数的帮助信息部分)-
- function changeicon(h,filename)
- %CHGICON changes the figure icon.
- % CHGICON(H,FILENAME) changes the icon of a figure to an image specified by
- % the string FILENAME, where H is a handle to the figure. If the file is not
- % in the current directory or in a directory in the MATLAB path,specify the
- % full pathname of the location on your system. If FILENAME is not a valid
- % image file name, the function just removes the previous icon of the figure.
- %
- % Example:
- % h = figure;
- % chgicon(h,'newIcon.png'); % replace 'newIcon.png' with your image
- %
- % IMPORTANT NOTES:
- % REPLACING THE MATLAB GUI ICON VIOLATES THE LICENSE AGREEMENT
- % OF MATLAB. DO NOT USE THIS FUNCTION COMMERCIALLY.
- %
- % Han Qun, Sept. 2005
- % Copyright 2005-2006 Han Qun
- % College of Precision Instrument and Opto-Electronics Engineering,
- % Tianjin University, 300072, P.R.China.
- % Email: junziyang@126.com
- % $Revision: 1.0 $ $Date: 2005/12/2 $
- if nargin<2
- error('MATLAB:chgicon','%s','Too few input arguments!');
- end
- if nargin >2
- error('MATLAB:chgicon','%s','Too many input arguments!');
- end
- newIcon = javax.swing.ImageIcon(filename);
- javaFrame = get(h,'JavaFrame');
- javaFrame.setFigureIcon(newIcon);
复制代码 |