|
以下代码是启动系统,出现登陆界面的通用Module。参数说明GuiFileName:gui文件名;WinCaption :应用程序窗口名称;AppPath:应用程序路径;PublicPath:公用module,gui文件路径。
public userID="0168";
public userPassword="";
#================================================================
function file_in_map(in file) #判断是否加载了gui
{
auto i,found=0,map_file[],map_file_num;
GUI_list_map_buffers(map_file,map_file_num);
for (i=1;i<=map_file_num;i++)
if (match(map_file[i],file)>0)
{
found = 1;
break;
}
return(found);
}
#================================================================
function LoginSystem(in PublicPath) #登录系统
{
auto LoginOK=0,found=0,r=E_OK;
found=file_in_map("Login.gui"); #注意大小写
if(found=="0")
r=GUI_load(PublicPath & "Login.gui");
if(r==E_OK)
{
if(win_exists("登 录 系 统",5)==E_OK)
{
# 登 录 系 统
set_window ("登 录 系 统", 8);
edit_set ("txtUserID", userID);
edit_set("txtPWD",userPassword);
button_press ("cmdOK");
if(win_exists("系统提示信息",1)!=E_OK)
LoginOK=1;
else
printf("登录用户名或密码不正确!");
}
else
printf("未启动登录界面!");
}
else
printf("找不到Login.gui!");
return(LoginOK);
}
#================================================================
function StartupApp(in GuiFileName,in WinCaption,in AppPath,in PublicPath) #启动系统
{
auto canRun=0,findGui=0,hasGui=E_OK,isStart,hWnd;
load_dll("user32.dll");
findGui=file_in_map(GuiFileName);
if(findGui=="0")
hasGui=GUI_load(GuiFileName);
if(hasGui==E_OK)
{
if(win_exists(WinCaption)!=E_OK)
{
isStart=invoke_application(AppPath,"","",SW_SHOWNORMAL);
if(isStart==E_OK)
{
if(LoginSystem(PublicPath)==1)
{
if(win_exists(WinCaption)==E_OK)
{
win_get_info(WinCaption, "handle", hWnd);
if(IsZoomed(hWnd)==0) win_max(WinCaption);
canRun=1;
}
else
printf("登录成功,但未出现窗体 " & WinCaption);
}
else
printf("登录失败!");
}
else
printf("启动 " & AppPath & " 失败!" );
}
else
{
win_get_info(WinCaption, "handle", hWnd);
if(IsIconic(hWnd)!=0) #如果窗体最小化时
win_restore(WinCaption);
if(IsZoomed(hWnd)==0) #如果窗体并不是最大化时
win_max(WinCaption);
canRun=1;
}
}
else
printf("未能加载" & GuiFileName);
return(canRun);
} |
|