| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2465 人关注过本帖
标题:设置工具栏出问题?
取消只看楼主 加入收藏
此在与世界
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2007-6-28
收藏
 问题点数:0 回复次数:2 
设置工具栏出问题?

X1=imread('打开.bmp');
X2=imread('保存.bmp');
X3=imread('打印.bmp');
X4=imread('放大.bmp');
X5=imread('undo.bmp');
X6=imread('redo.bmp');
% 建立工具栏
uipushtool('Separator','on','TooltipString','打开','ClickedCallback',...
@open_Callback,'CData',X1);
uipushtool('Separator','on','TooltipString','保存','ClickedCallback',...
@save_Callback,'CData',X2);
uipushtool('Separator','on','TooltipString','打印','ClickedCallback',...
'printdlg','CData',X3);
uipushtool('Separator','on','TooltipString','放大','ClickedCallback',...
@image_zoom_Callback,'CData',X4);
uipushtool('Separator','on','TooltipString','撤消','ClickedCallback',...
@remove_Callback,'CData',X5);
uipushtool('Separator','on','TooltipString','恢复','ClickedCallback',...
@resume_Callback,'CData',X6);

创建工具栏成功,但是只有open能正常使用,其它的都提示

?? Input argument "handles" is undefined.

??? Error while evaluating uipushtool ClickedCallback.

这是为什么,请指教,open_Callback里也用到handles!

搜索更多相关主题的帖子: 工具栏 bmp imread Separator Callback 
2007-10-20 09:22
此在与世界
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2007-6-28
收藏
得分:0 

function varargout = Myprogram1(varargin)
% MYPROGRAM1 M-file for Myprogram1.fig
% MYPROGRAM1, by itself, creates a new MYPROGRAM1 or raises the existing
% singleton*.
%
% H = MYPROGRAM1 returns the handle to a new MYPROGRAM1 or the handle to
% the existing singleton*.
%
% MYPROGRAM1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MYPROGRAM1.M with the given input arguments.
%
% MYPROGRAM1('Property','Value',...) creates a new MYPROGRAM1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Myprogram1_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Myprogram1_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help Myprogram1

% Last Modified by GUIDE v2.5 17-Oct-2007 09:50:07

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Myprogram1_OpeningFcn, ...
'gui_OutputFcn', @Myprogram1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Myprogram1 is made visible.
function Myprogram1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Myprogram1 (see VARARGIN)

% Choose default command line output for Myprogram1
handles.output = hObject;

% 读取工具栏图象数据
X1=imread('打开.bmp');
X2=imread('保存.bmp');
X3=imread('打印.bmp');
X4=imread('放大.bmp');
X5=imread('undo.bmp');
X6=imread('redo.bmp');
% 建立工具栏
htb=uitoolbar;
uipushtool(htb,'Separator','on','TooltipString','打开','ClickedCallback',...
@open_Callback,'CData',X1);
uipushtool(htb,'Separator','on','TooltipString','保存','ClickedCallback',...
@save_Callback,'CData',X2);
uipushtool(htb,'Separator','on','TooltipString','打印','ClickedCallback',...
'printdlg','CData',X3);
uipushtool(htb,'Separator','on','TooltipString','放大','ClickedCallback',...
@image_zoom_Callback,'CData',X4);
uipushtool(htb,'Separator','on','TooltipString','撤消','ClickedCallback',...
@remove_Callback,'CData',X5);
uipushtool(htb,'Separator','on','TooltipString','恢复','ClickedCallback',...
@resume_Callback,'CData',X6);
h=findobj(hObject,'type','figure');
% 设置发布的GUI的属性
set(h,'resize','on');
set(h,'CloseRequestFcn','quest');
set(h,'handlevisibility','off');
set(h,'HitTest','off');

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Myprogram1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.

function varargout = Myprogram1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% --------------------------------------------------------------------
% --------------------------------------------------------------------
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uigetfile({'*.jpg','image file(*.jpg)';'*.bmp','image file(*.bmp)';...
'*.tif','image file(*.tif)';'*.hdf','image file(*.hdf)';...
'*.png','image file(*.hdf)';'*.xwd','image file(*.xwd)'},...
'Open Image File');
if(isequal([filename,pathname],[0,0]))
return;
end
cd(pathname);
data=imread(filename);
hfigure=figure;
imshow(data);
set(hfigure,'resize','on','MenuBar','none');
handles.data=data;
handles.hfigure=hfigure;
guidata(hObject,handles);

% --------------------------------------------------------------------
% --------------------------------------------------------------------
function save_Callback(hObject, eventdata, handles)
% hObject handle to save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uiputfile({'*.jpg','image file(*.jpg)';'*.bmp','image file(*.bmp)';...
'*.tif','image file(*.tif)';'*.hdf','image file(*.hdf)';...
'*.png','image file(*.hdf)';'*.xwd','image file(*.xwd)'},...
'Save');
cd(pathname)
if isequal([filename,pathname],[0,0])
return;
end
if ~isfield(handles,'data')
return;
end
data=handles.data;
imwrite(data,filename);

2007-10-27 19:50
此在与世界
Rank: 1
等 级:新手上路
帖 子:38
专家分:0
注 册:2007-6-28
收藏
得分:0 
终于好了,我最近折腾来折腾去,还是一塌糊涂啊。实在太感谢了!
2007-10-31 08:52
快速回复:设置工具栏出问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017849 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved