高手:我想把电脑随机数实时显示在编辑框中 (我已经在编辑框中,定义了一个浮点型变量 m_max_z)
for(int i=0; i<data; i++)   //  
{
p[i] = rand() % (int)(Max)+1;   // 产生0-100的随机数
        m_max_z=p[i];
         }
我这个循环在在Mychild绘图函数中,我想让p[i];绘图,m_max_z在编辑框中显示数据程序报错
C:\Documents and Settings\000Mychild.cpp(412) : error C2065: 'm_max_z' : undeclared identifier我想:可能是Mychild是CWnd派生的类,对话框类为:MyDlg现在不知怎么改了

解决方案 »

  1.   

    你的对话框和你的view类有什么关联吗?比如你的对话框是作为View类的子窗口?
      

  2.   

    传编辑框指针给非主框架类,或使用 AfxGetApp()->GetMainWnd()
      

  3.   

    用自定义消息发过去
    你看看这篇文章会不会对你有帮助
    http://blog.csdn.net/xianglitian/article/details/6729851
      

  4.   

    如果程MyDlg为主对话框,即你的程序就一个对话框
      假设你的m_max_z变量是public的直接
      (AfxGetApp()->GetMainWnd()).m_max_z=p[i];
      你的m_max_z变量是private、protected的
       在MyDlg添加一方法,SetValue(double a);
       然后
        (AfxGetApp()->GetMainWnd()).SetValue(p[i]);
    设置完 后 UpdateData();
      

  5.   

    'm_max_z' : undeclared identifier没定义,没有把'm_max_z' 传递到该类
      

  6.   

    gameslq 这位高手我试过后 程序报错
    F:\VC\双绘图区 \MyLine.cpp(438) : error C2228: left of '.m_max_z' must have class/struct/union type我这里的m_max_z是浮点式变量,程序怎么要求是类呢