| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 812 人关注过本帖
标题:MFC中窗口的弹出,小弟新手
只看楼主 加入收藏
yangjinze
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2011-10-2
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:6 
MFC中窗口的弹出,小弟新手
我是用MFC的基本对话框来做程序的,想要在登录窗口输入账号密码点击确认后,弹出主窗口,但每次输完点击后程序都直接关掉,下面是 CShangweijiAPP中INit**中我所写的代码,希望高手指教
CDengLu dlg;
    m_pMainWnd = &dlg;//程序运行首先启动登陆窗口
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with OK
        CShangweijiDlg zhu_dlg;//单击确定后出现程序主窗口
        zhu_dlg.DoModal();
    }
    else if (nResponse == IDCANCEL)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with Cancel
    }

    // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
搜索更多相关主题的帖子: 密码 对话框 账号 
2012-04-08 20:22
yangjinze
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2011-10-2
收藏
得分:0 
其中我对确定按钮有添加这些代码void CDengLu::OnOK() //登录窗口确定键的功能,判断输入的用户名与密码
{
    // TODO: Add extra validation here
    CString str_user;
    CString str_password;
    GetDlgItemText(IDC_EDIT_Name,str_user);
    GetDlgItemText(IDC_EDIT_PassWord,str_password);

    if(str_user.IsEmpty()||str_password.IsEmpty())//判断输入是否为空
    {
    MessageBox("用户名或者密码不能为空!");
    }

    else if(str_user=="123"&&str_password=="123")//测试账号密码123
    {
    //MessageBox("欢迎光临");
    //denglu=1;
   
   
    }
    else
    {
    MessageBox("用户名或者密码错误!");
    }
    CDialog::OnOK();
}
2012-04-08 20:37
zamboninite
Rank: 2
等 级:论坛游民
帖 子:66
专家分:20
注 册:2007-10-6
收藏
得分:20 
CDengLu dlg;
   
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
        // TODO: Place code here to handle when the dialog is
        //  dismissed with OK
        CShangweijiDlg zhu_dlg;//单击确定后出现程序主窗口

        m_pMainWnd = &zhu_dlg;//注意这一行****************
        zhu_dlg.DoModal();
    }
2012-04-09 13:05
zamboninite
Rank: 2
等 级:论坛游民
帖 子:66
专家分:20
注 册:2007-10-6
收藏
得分:0 
///// m_pMainWnd = &dlg;//程序运行首先启动登陆窗口
记得这一行要去掉啊
2012-04-09 13:07
yangjinze
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2011-10-2
收藏
得分:0 
回复 3楼 zamboninite
大哥不行啊
C:\Documents and Settings\Administrator\桌面\shangweiji\DengLu1.cpp(62) : error C2065: 'CShangweijiDlg' : undeclared identifier
2012-04-09 16:41
yangjinze
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2011-10-2
收藏
得分:0 
回复 3楼 zamboninite
高手谢谢啊,可以了,我写错位置了平
2012-04-09 16:48
yangjinze
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2011-10-2
收藏
得分:0 
回复 4楼 zamboninite
再次感谢
2012-04-09 16:55
快速回复:MFC中窗口的弹出,小弟新手
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014410 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved