Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2008-10-18
年龄: 42
帖子: 5
声望力: 0 ![]() |
![]()
今天本来想下载一个密码登陆窗口的程序,无奈没有金币,只好自己花了几个小时,编了这个简单的小程序,和大家互相交流下。。。小弟学这个才两周不到。。。
:) 使用方法: 将附件解压至英文目录下,打开matlab 7.0,输入命令GUIDE,选择a1.fig。 用户名:dafei0214 密码:87406 登陆成功后会启动系统界面。 欢迎大家多提意见。。。 QQ:335340681 |
![]() |
![]() |
![]() |
#2 |
初级会员
注册日期: 2008-10-18
年龄: 42
帖子: 5
声望力: 0 ![]() |
![]()
这个是截图。。。
|
![]() |
![]() |
![]() |
#3 |
初级会员
注册日期: 2008-10-27
年龄: 37
帖子: 4
声望力: 0 ![]() |
![]()
为啥没人顶呢 。。
|
![]() |
![]() |
![]() |
#4 |
普通会员
注册日期: 2007-08-07
帖子: 64
声望力: 20 ![]() |
![]()
我发一个免费的,我可不是跟楼主对着干,互相交流而已。
function mima OldHandle = findobj( 'Type', 'figure', 'Tag', 'mimadenglu' ) ; if ishandle( OldHandle ) close( OldHandle ) ; end fig = figure ; set(fig,'units','normalized','position',[0.3 0.2 0.4 0.6],... 'menubar','none','name','密码登陆窗口',... 'numbertitle','off','color',[0.925 0.914 0.847],'tag','mimadenglu'); scnsize=get(0,'screensize'); font_size1=round(20*sqrt(scnsize(3)*scnsize(4)/(1024*768))); font_size2=round(14*sqrt(scnsize(3)*scnsize(4)/(1024*768))); uicontrol(fig,'style','text','units','normalized','pos',[0.1 0.63 0.8 0.15],'string','欢迎使用本系统',... 'fontsize',font_size1,'fontweight','bold','fontunits','normalized','bac',[0.925 0.914 0.847]) panel1=uipanel(fig,'units','normalized','pos',[0.15 0.3 0.7 0.15],'bac',[0.925 0.914 0.847]); uicontrol(panel1,'style','edit','units','normalized','pos',[0.2 0.2 0.6 0.6],... 'string','','tag','edit1','backgroundcolor',[1 1 1],'string','请输入密码',... 'fontsize',font_size2,'fontunits','normalized','KeyPressFcn',... ['currKey = get(gcf,''Currentkey'');',... 'currChar = get(gcf,''Currentcharacter'');',... 'switch currKey;',... 'case {''backspace'',''delete''};',... 'Char = [];',... 'set(gcbo,''String'','''');',... 'drawnow;',... 'case ''return'';',... 'passChar = get(gcbo,''UserData'');',... 'if strcmp(passChar,''654321'');',... 'msgbox(''恭喜你记住了密码!!!'');',... 'else;',... 'msgbox(''密码输入错误!!!'');',... 'end;',... 'return;',... 'otherwise;',... 'oldChar = get(gcbo,''UserData'');',... 'Char = [oldChar,currChar];',... 'set(gcbo,''string'',char(''*''*ones(1,length(Char))));',... 'end;',... 'set(gcbo,''UserData'',Char);']) |
![]() |
![]() |
![]() |
#5 |
普通会员
注册日期: 2008-04-12
年龄: 46
帖子: 67
声望力: 19 ![]() |
![]()
这个东西应该说基本没啥技术含量.
|
![]() |
![]() |
![]() |
#6 |
高级会员
注册日期: 2008-10-21
年龄: 40
帖子: 198
声望力: 22 ![]() ![]() |
![]()
好好的要个这做什么!!!!!!!!
真是的!!!!!
__________________
matlab太高深了!!!!!!!:ft: |
![]() |
![]() |
![]() |
#7 |
初级会员
注册日期: 2008-10-18
年龄: 42
帖子: 5
声望力: 0 ![]() |
![]()
搞这个纯属好玩来着,没想要大家买啊。。。。大家交流下吧。。。虽说很简单,但如果在做保密性较高的项目时还是必要的。
具体思路:输入密码时,在keypress函数里检测输入的按键,如果是图形字符,显示星号,并讲键入的字符存为全局变量,当输入del或backspace时,清除全局变量和星号;当输入为enter或点击确认时,开始比较所键入的全局变量值与密码,当然,用户名要对应密码。 function varargout = a1(varargin) % A1 M-file for a1.fig % A1, by itself, creates a new A1 or raises the existing % singleton*. % % H = A1 returns the handle to a new A1 or the handle to % the existing singleton*. % % A1('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in A1.M with the given input arguments. % % A1('Property','Value',...) creates a new A1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before a1_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to a1_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 a1 % Last Modified by GUIDE v2.5 25-Oct-2008 21:22:30 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @a1_OpeningFcn, ... 'gui_OutputFcn', @a1_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 a1 is made visible. function a1_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 a1 (see VARARGIN) % Choose default command line output for a1 handles.output = hObject; set(handles.a1_code,'String',''); set(handles.a1_user,'String',''); handles.xinghao = ''; handles.user='dafei0214'; handles.code='87406'; % Update handles structure guidata(hObject, handles); % UIWAIT makes a1 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = a1_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 a1_user_Callback(hObject, eventdata, handles) % hObject handle to a1_user (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of a1_user as text % str2double(get(hObject,'String')) returns contents of a1_user as a double % --- Executes during object creation, after setting all properties. function a1_user_CreateFcn(hObject, eventdata, handles) % hObject handle to a1_user (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function a1_code_Callback(hObject, eventdata, handles) % hObject handle to a1_code (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)set(hObject,'foregroundcolor',[1 1 1]); 40% Hints: get(hObject,'String') returns contents of a1_code as text % str2double(get(hObject,'String')) returns contents of a1_code as a double % set(handles.a1_code,'foregroundcolor',[1 1 1]); % --- Executes during object creation, after setting all properties. function a1_code_CreateFcn(hObject, eventdata, handles) % hObject handle to a1_code (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. set(hObject,'UserData',''); set(hObject,'String',''); if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in a1_cancer. function a1_cancer_Callback(hObject, eventdata, handles) % hObject handle to a1_cancer (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % set(handles.a1_user,'UserData','','string',''); set(handles.a1_code,'UserData','','string',''); close(gcf); clear clc % --- Executes on button press in a1_ok. function a1_ok_Callback(hObject, eventdata, handles) % hObject handle to a1_ok (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) passChar = get(handles.a1_code,'UserData'); userChar = get(handles.a1_user,'String'); if strcmp(passChar,handles.code)&strcmp(userChar,handles.user) % msgbox('登陆成功!'); close(gcf); close(a1); figure(lianxi02); set(gcf,'name','系统界面BY罗华飞QQ335340681'); else set(handles.a1_code,'string','','UserData',''); msgbox('用户名或密码错误!'); handles.xinghao=''; guidata(hObject,handles); end % --- Executes when figure1 is resized. function figure1_ResizeFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on key press over a1_code with no controls selected. function a1_code_KeyPressFcn(hObject, eventdata, handles) % hObject handle to a1_code (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % set(hObject,'fontSize',10); currChar = get(gcf,'CurrentCharacter'); oldChar = get(hObject,'UserData'); xinghao=get(hObject,'string'); userChar=get(handles.a1_user,'string'); if isstrprop(currChar,'graphic') oldChar = [oldChar currChar]; xinghao=[handles.xinghao '*']; set(hObject,'UserData',oldChar,'string',xinghao); handles.xinghao=xinghao; guidata(hObject,handles); elseif double(currChar)==26|double(currChar)==8 oldChar=''; handles.xinghao=''; set(hObject,'UserData',oldChar,'string',handles.xinghao); guidata(hObject,handles); elseif double(currChar)==13 set(hObject,'string',xinghao); if strcmp(oldChar,handles.code)&strcmp(userChar,handles.user) % msgbox('登陆成功!'); close(gcf); close(a1); figure(lianxi02); set(gcf,'name','系统界面BY罗华飞QQ335340681'); else set(hObject,'string','','UserData',''); handles.xinghao=''; guidata(hObject,handles); msgbox('用户名或密码错误!'); handles.xinghao=''; guidata(hObject,handles); end else set(hObject,'UserData',oldChar); set(hObject,'string',handles.xinghao); end |
![]() |
![]() |
![]() |
#8 |
初级会员
注册日期: 2008-10-11
年龄: 42
帖子: 1
声望力: 0 ![]() |
![]()
能不能写一个可以让用户有权限去更改用户名和密码的?
|
![]() |
![]() |
![]() |
#9 |
初级会员
注册日期: 2007-06-24
年龄: 42
帖子: 13
声望力: 18 ![]() |
![]() |
![]() |
![]() |
![]() |
#10 |
初级会员
注册日期: 2008-11-30
年龄: 39
帖子: 7
声望力: 0 ![]() |
![]()
以上两位高手的源代码在我这运行的时候都显示的是Error: Missing variable or function.请告诉原因吧
![]()
__________________
小朴 |
![]() |
![]() |
![]() |
|
|
![]() |
||||
主题 | 主题作者 | 版面 | 回复 | 最后发表 |
[求助]:如何用matlab计算协谱 | dzytaste | MATLAB论坛 | 1 | 2010-04-08 21:04 |
[求助]那位仁兄有MATLAB里的经典图片? | lwwj136 | MATLAB论坛 | 0 | 2009-01-12 11:42 |
[求助]负反馈电路的仿真 | necy | MATLAB论坛 | 0 | 2008-12-01 20:59 |
[求助]各位达人 | beardgh | MATLAB论坛 | 0 | 2008-09-19 16:34 |
[求助]请各位大哥帮帮忙 | warlock8238 | MATLAB论坛 | 3 | 2008-09-14 15:31 |