源于StarGate,做登陆模块需要这个.
将CDialogLogin(登陆对话框的类)的值传递到View类中,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void CChildView::OnLoginLogout()
{
// TODO: 在此添加命令处理程序代码
if(FALSE==m_LogInOut)
{
// 打开登陆窗口
CDialogLogin DlgLogin;
if(IDOK==DlgLogin.DoModal())
{
m_VpnSrvPayUserName=DlgLogin.m_LoginUserName;
m_VpnSrvPayPassWord=DlgLogin.m_LoginPassWord;
CMenu* tmpMenu=AfxGetMainWnd()->GetMenu();
tmpMenu->ModifyMenu(0,MF_BYPOSITION,IDM_LOGIN_LOGOUT,_T("注销"));
m_LogInOut=TRUE;
}
}
else
{
m_VpnSrvPayUserName=_T("");
m_VpnSrvPayPassWord=_T("");
CMenu* tmpMenu=AfxGetMainWnd()->GetMenu();
tmpMenu->ModifyMenu(0,MF_BYPOSITION,IDM_LOGIN_LOGOUT,_T("登陆"));
m_LogInOut=FALSE;
}
}

如上,我用View类变量m_LogInOut来判断当前是登陆还是未登录状态,主要是这些

1
2
3
4
5
6
7
CDialogLogin DlgLogin;
if(IDOK==DlgLogin.DoModal())
{
m_VpnSrvPayUserName=DlgLogin.m_LoginUserName;
m_VpnSrvPayPassWord=DlgLogin.m_LoginPassWord;
……
}