声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 865|回复: 2

[编程技巧] 系统登录框问题

[复制链接]
发表于 2008-6-15 15:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
做系统的登录框:想把edit中的输入数据变为*,希望大家帮忙一下
回复
分享到:

使用道具 举报

发表于 2008-6-16 18:48 | 显示全部楼层
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);'])

评分

1

查看全部评分

 楼主| 发表于 2008-6-17 09:58 | 显示全部楼层

回复 2楼 的帖子

找了半天了,谢谢了,我会好好学习一下!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-23 09:25 , Processed in 0.064639 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表