代码如下
         CString str1;
extern char m_phone[50];
extern int count;
int n=0;
    GetDlgItemText(IDC_DESKEY,str1);
    if(str1.GetLength()==0)
{
this->MessageBox("请先输入密钥");
return;
}
    else if (str1.GetLength()>=9)
{
this->MessageBox("密钥过长,请重新输入");
return;
}
for(n=0;n<=count;n++)
{
    char skey[32];
    char inbuff[32],oubuff[32];
memcpy(skey,(LPCTSTR)m_key,8);
memcpy(inbuff,(LPCTSTR)m_phone[n],8);    CString strTmp,str;    DES jm ;
    jm.Des_Go(oubuff, inbuff, sizeof(inbuff), skey,sizeof(skey), ENCRYPT);
    for(int i=0;i<32;i++)
    str+=oubuff[i];     
    m_listctrl.SetItemText(0,2,str);
    }编译错误,'m_listctrl' : undeclared identifier,请问如何能正确引用,还有m_phone[50]与count也是在父对话框中某函数定义的,如此引用是否正确?

解决方案 »

  1.   

    我觉得你表述应该是错的
    可以用GetParent()获取父窗口的指针
      

  2.   

    不是父进程,是2个对话框,m_listctrl在父对话框中,而此函数在子对话框
      

  3.   

    “还有m_phone[50]与count也是在父对话框中某函数定义的”
    可以把m_phone[50]与count作为父对话框的成员变量
      

  4.   

     ((主对话框*)GetParent())->m_listctrl.SetItemText(0,2,str)
    ((主对话框*)GetParent())->m_phone[50]
    ((主对话框*)GetParent())->count
      

  5.   

    如果父对话框就是主对话框可以通过AfxGetMainWnd获取其指针
    进而引用其变量
    或者通过GetParent获取父窗口句柄
    然后通过自定义消息让父窗口自己完成相关操作
      

  6.   

    m_listctrl已经解决,可是m_phone[50]和count不是在类里定义的关联变量,而是在父对话框的void CAdo2Dlg::OnQuery()里定义的