|
我写过这样一段代码,希望对你有用:
public function Login_Errorshow(in ErrorForm,in MainForm,in LoginForm)
{
auto msg,ErrorState;
if (win_exists(ErrorForm,1)==E_OK)
{
set_window(ErrorForm);
static_get_text("ErrorStatic",msg);
switch(msg)
{
case Er_NoUserID: #Er_NoUserID定义成常量,值为错误提示窗体的static
{
set_window(ErrorForm);
button_press("TBtn_Confirm");
ErrorState=E_NO_USERID;
printf(" 异常状态—"& E_NO_USERID &"未输入用户代码");
break;
}
case Er_InvalidUserPsw:
{
set_window(ErrorForm);
button_press("TBtn_Confirm");
ErrorState=E_USERPSW_INVALID;
printf(" 异常状态—"& E_USERPSW_INVALID &"用户密码错误");
break;
}
case Er_NoExistUserID:
{
set_window(ErrorForm);
button_press("TBtn_Confirm");
ErrorState=E_USERID_NOEXIST;
printf(" 异常状态—"& E_USERID_NOEXIST &"用户代码不存在");
break;
}
case Er_UnsafeUser:
{
set_window(ErrorForm);
button_press("TBtn_Confirm");
ErrorState=E_USERID_UNSAFED;
printf(" 异常状态—"& E_USERID_UNSAFED &"三次密码错误");
break;
}
default :
{
set_window(ErrorForm);
button_press("TBtn_Confirm");
ErrorState=E_ANY_ERROR;
printf(" 异常状态—"& E_ANY_ERROR &msg);
}
}
return(ErrorState);
}
# else if (win_exists(MainForm)==E_OK)
# {
# set_window(MainForm);
# printf("登录成功");
# win_close(MainForm);
# set_window ("Quest_Form");
# button_press ("TBtn_Yes");
# return(E_LOGIN_OK);
# }
# else
# {
# set_window(LoginForm);
# obj_mouse_click ("TBtn_Exit", 46, 12, LEFT);
# }
}
public function StartSystem(in GuiFileName,in AppName)
{
auto canrun=0,guistatus,isStart;
GUI_close(GuiFileName);
guistatus=Guifile_in_map(GuiFileName);
if (guistatus==1)
{
isStart=invoke_application(AppName,"","",SW_SHOWMAXIMIZED);
if (isStart==E_OK)
canrun=1;
else
printf(AppName & "运行失败");
}
else
printf(GuiFileName &"载入异常");
return(canrun);
}
#*******************************************************************************
# * 功能描述:
# * 登录模块
# * 输入参数:
# LoginGui:登录时的Gui Map文件;
# * ErrorForm: 错误窗体的逻辑名;
# MainFrom:登录成功后的主窗体;
# LoginForm:登录窗体;
# * 输出参数:
# * 无
# * 返回值:
# * Res:错误状态{-1,0...17},用于其他过程调用;
# * 历史纪录:
# * 修改人 日期 版本号 描述
# * winterson 2005/11/23 第一次创建
#*******************************************************************************/
public function LoginSystem(in LoginGui,in ErrorForm,in MainForm,in LoginForm,in UserID,in UserMiMa)
{
auto found=0,Rgui,rc,msg,Res,currwin;
GUI_close(LoginGui);
Rgui=Guifile_in_map(LoginGui);
if (Rgui!=1)
{
printf(LoginGui &"载入失败");
texit;
}
set_window (LoginForm,1);
edit_set("TEdt_UserID",UserID);
edit_set("TEdt_UserPsw",UserMiMa);
obj_mouse_click("TBtn_Confirm",54, 10, LEFT);
if (rc==0)
{
rc=1;
set_window("Er_Form_NoConnect");
static_get_text("Static_ConnectError",msg);
printf(msg);
button_press("TBtn_Yes");
}
else
{
if (win_exists("Er_Form_NoConnect",1)==E_OK)
rc=0;
}
Res=Login_Errorshow(ErrorForm,MainForm,LoginForm);
while (Res!=E_LOGIN_OK)
{
Res=Login_Errorshow(ErrorForm,MainForm,LoginForm);
}
return(Res);
} |
|