+ -
当前位置:首页 → 问答吧 → 紧急求助:MFC Tab Control 中的Edit Control问题

紧急求助:MFC Tab Control 中的Edit Control问题

时间:2011-12-15

来源:互联网

各位CSDN大神
小弟在MFC编程的时候遇到了一个严重的问题
具体内容在下面
我最近写了个程序
界面如下


当点击 “启动系统后”
会在 Tab Control中显示一条信息
如下


但是这里就出现了一个问题
其他的Tab Contorl也出现了相同的字符

以下是代码

启动按钮
C/C++ code

//启动系统
void CCommPayDlg::StartSystem()
{
    mainThread->StartProgram();
}


启动按钮功能实现
C/C++ code

//启动系统
void mMain_Thread::StartProgram()
{
    GlobleValues *app=(GlobleValues *)AfxGetApp();
    if(System_RUN==SYSTEMRUN)
    {
        app->Msg->ShowMsg_SYS(SYSGENERAL,"aaaa",app->Edit_SYS);
        return;
    }
    else
    {
        CString str="删除数据库中信息";
        //app->SQLConn->DeleteTempData();
                //这里就是显示信息方法
        app->Msg->ShowMsg_SYS(SYSGENERAL,str,app->Edit_SYS);
        System_RUN=SYSTEMRUN;
    }
}


显示信息方法实现
C/C++ code

//显示系统信息
void ShowMsg::ShowMsg_SYS(int nStatus,CString s,CEdit *edit)
{
    int i;
    CTime t=CTime::GetCurrentTime();
    CString str;
    CString strT=t.Format("%Y-%m-%d %H:%M:%S");
    CString strInfo="系统信息\r\n时间:";
    strInfo+=strT;
    strInfo+="\r\n";
    switch(nStatus)
    {
    case SYSERROR:
        str="系统错误:";
        strInfo+=str;
        break;
    case  SYSDATAREAD:
        str="数据库读取信息:";
        strInfo+=str;
        break;
    case SYSTHREAD:
        str="系统线程信息:";
        strInfo+=str;
        break;
    case SYSGENERAL:
        str="系统信息:";
        strInfo+=str;
        break;
    }
    strInfo=strInfo+s+"\r\n\r\n";
    if((AirTopMsg->MsgCache_SYS.GetLength()+strInfo.GetLength())>=MAXCACHE)
    {
        AirTopMsg->MsgCache_SYS.Empty();
        AirTopMsg->MsgCache_SYS.FreeExtra();
        AirTopMsg->MsgCache_SYS.GetBufferSetLength(MAXCACHE);
    }
    AirTopMsg->MsgCache_SYS.Format("%s%s",AirTopMsg->MsgCache_SYS,strInfo);
    edit->SetWindowText(AirTopMsg->MsgCache_SYS);
    i=edit->GetWindowTextLength();
    edit->SetFocus();
    edit->SetSel(i,i);
    edit->ReplaceSel("\r\n");
}



启动按钮功能实现中的app是一个全局变量
C/C++ code

class GlobleValues : public CWinApp
{
public:
    //电信消息框
    CEdit *Edit_DX;
    //联通消息框
    CEdit *Edit_LT;
    //移动消息框
    CEdit *Edit_YD;
    //系统消息框
    CEdit *Edit_SYS;
}

实现是在界面初始化中
C/C++ code

        //初始化全局变量
    app=(GlobleValues *)AfxGetApp();
    app->Edit_DX=&DX_page.Edit_DX;
    app->Edit_LT=&LT_page.Edit_LT;
    app->Edit_YD=&YD_page.Edit_YD;
    app->Edit_SYS=&SYS_page.Edit_SYS;

作者: gao337536127   发布时间: 2011-12-15

如果有不明白的可以提出来下
我可以把工程文件发出来

作者: gao337536127   发布时间: 2011-12-15