sdl0819 发表于 2002-12-20 10:34:00

为什么m_x已在ScaleDlg.h中定义过,而在ScaleDlg.cpp却不认可?

ScaleDlg.h文件内容:
#if !defined(AFX_SCALEDLG_H__883BC861_1336_11D7_A714_885276570047__INCLUDED_)
#define AFX_SCALEDLG_H__883BC861_1336_11D7_A714_885276570047__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ScaleDlg.h : header file
//
#include "resource.h"
#include
#include
#include
/////////////////////////////////////////////////////////////////////////////
// CScaleDlg dialog
class CScaleDlg : public CAcUiDialog
{
// Construction
public:
      CScaleDlg(CWnd* pParent = NULL);   // standard constructor
    void DisplayComboBox();
// Dialog Data
      //{{AFX_DATA(CScaleDlg)
      enum { IDD = IDD_DIALOG1 };
      CAcUiSymbolComboBox      m_x;
      CAcUiSymbolComboBox      m_y;
      CAcUiSymbolComboBox      m_p;
      //}}AFX_DATA
// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CScaleDlg)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      //}}AFX_VIRTUAL
// Implementation
protected:
      // Generated message map functions
      //{{AFX_MSG(CScaleDlg)
      virtual BOOL OnInitDialog();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SCALEDLG_H__883BC861_1336_11D7_A714_885276570047__INCLUDED_)
ScaleDlg.cpp文件内容:
// ScaleDlg.cpp : implementation file
//
#include "StdAfx.h"
#include "ScaleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScaleDlg dialog
CScaleDlg::CScaleDlg(CWnd* pParent /*=NULL*/)
      : CAcUiDialog(CScaleDlg::IDD, pParent)
{
      //{{AFX_DATA_INIT(CScaleDlg)
      //}}AFX_DATA_INIT
}
void CScaleDlg:oDataExchange(CDataExchange* pDX)
{
      CAcUiDialog:oDataExchange(pDX);
      //{{AFX_DATA_MAP(CScaleDlg)
      DDX_Control(pDX, IDC_COMBO_X, m_x);
      DDX_Control(pDX, IDC_COMBO_Y, m_y);
      DDX_Control(pDX, IDC_COMBO_P, m_p);
      //}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CScaleDlg, CAcUiDialog)
      //{{AFX_MSG_MAP(CScaleDlg)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScaleDlg message handlers
BOOL CScaleDlg::OnInitDialog()
{
      CAcUiDialog::OnInitDialog();
      // TODO: Add extra initialization here
   DisplayComboBox();
   return TRUE;// return TRUE unless you set the focus to a control
                      // EXCEPTION: OCX Property Pages should return FALSE
}
void DisplayComboBox()
{
m_x.InsertString(-1,"good");
}
编译出现:
d:\LX\scale\ScaleDlg.cpp(55) : error C2065: 'm_x' : undeclared identifier
d:\LX\scale\ScaleDlg.cpp(55) : error C2228: left of '.InsertString' must have class/struct/union type
这是为什么?为什么m_x已经在ScaleDlg.h文件中定义过,而在ScaleDlg.cpp的
void DisplayComboBox()
{
m_x.InsertString(-1,"good");
}
中,却不认可?
请各位高手帮助一下,谢谢!
e_mail:msd0819@mail.dlptt.ln.cn

CAD菜鸟 发表于 2002-12-20 10:38:00

你的程序中
void DisplayComboBox()
{
m_x.InsertString(-1,"good");
}
应为
void CScaleDlg:isplayComboBox()
{
m_x.InsertString(-1,"good");
}
就行了。
页: [1]
查看完整版本: 为什么m_x已在ScaleDlg.h中定义过,而在ScaleDlg.cpp却不认可?