天天看點

程式又出問題了,不知怎麼了

// CityZoneDlg.cpp : implementation file

//

#include "stdafx.h"

#include "Ex_CityCode2.h"

#include "CityZoneDlg.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/

// CCityZoneDlg dialog

CCityZoneDlg::CCityZoneDlg(CWnd* pParent )

 : CDialog(CCityZoneDlg::IDD, pParent)

{

 //{{AFX_DATA_INIT(CCityZoneDlg)

  // NOTE: the ClassWizard will add member initialization here

 //}}AFX_DATA_INIT

}

void CCityZoneDlg::DoDataExchange(CDataExchange* pDX)

{

 CDialog::DoDataExchange(pDX);

 //{{AFX_DATA_MAP(CCityZoneDlg)

  // NOTE: the ClassWizard will add DDX and DDV calls here

 //}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CCityZoneDlg, CDialog)

 //{{AFX_MSG_MAP(CCityZoneDlg)

 ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)

 ON_BN_CLICKED(IDC_BUTTON_CHANGE, OnButtonChange)

 ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)

 ON_WM_DESTROY()

 //}}AFX_MSG_MAP

END_MESSAGE_MAP()

/

// CCityZoneDlg message handlers

BOOL CCityZoneDlg::IsValidate()

{

UpdateData();

m_strCity.TrimLeft();

if(m_strCity.IsEmpty())

{MessageBox("城市名輸入無效!");return FALSE;

}

m_strZip.TrimLeft();

if(m_strZip.Isvalidate())

{MessageBox("郵政編碼輸入無效!");return FALSE;

}

m_strZone.TrimLeft();

if(m_strZone.Isvalidate())

{MessageBox("區号輸入無效!");return FALSE;

}

return TRUE;

}

void CCityZoneDlg::OnButtonAdd()

{

 // TODO: Add your control notification handler code here

if(!Isvalidate()) return;

int nIndex=m_ComboBox.FindStringExact(-1,m_strCity);

if(nIndex!=CB_ERR)

{MessageBox("該城市已添加!");return;}

CString strData;

strData.Format("%s,%s",m_strZip,m_strZone);

m_ComboBox.SetItemDataPtr(nIndex,new CString(strData));

}

void CCityZoneDlg::OnButtonChange()

{

 // TODO: Add your control notification handler code here

if(!Isvalidate()) return;

int nIndex=m_ComboBox.FindStringExact(-1,m_strCity);

if(nIndex!=CB_ERR) 

{delete(CString*)m_ComboBox.GetItemDataPtr(nIndex);

 CString strData;

strData.Format("%s,%s",m_strZip,m_strZone);

m_ComboBox.SetItemDataPtr(nIndex,new CString(strData));

}

void CCityZoneDlg::OnSelchangeCombo1()

{

 // TODO: Add your control notification handler code here

int nIndex=m_ComboBox.GetCurSel();

if(nIndex!=CB_ERR)

{m_ComboBox.GetLBText(nIndex,m_strCity);

CString strData=*(CString*)m_ComboBox.GetItemDataPtr(nIndex);

int n=strData.Find(',');

m_strZip=strData.Left(n);

m_strZone=strData.Mid(n+1);

UpdateData(FALSE);

}

void CCityZoneDlg::OnDestroy()

{

 CDialog::OnDestroy();

 // TODO: Add your message handler code here

for(int nIndex=m_ComboBox.GetCount()-1;nIndex>=0;nIndex)

delete(CString*)m_ComboBox.GetItemDataPtr(nIndex);

}

-------------------Configuration: Ex_CityCode2 - Win32 Debug--------------------

Compiling...

CityZoneDlg.cpp

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(51) : error C2065: 'm_strCity' : undeclared identifier

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(51) : error C2228: left of '.TrimLeft' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(52) : error C2228: left of '.IsEmpty' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(55) : error C2065: 'm_strZip' : undeclared identifier

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(55) : error C2228: left of '.TrimLeft' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(56) : error C2228: left of '.Isvalidate' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(59) : error C2065: 'm_strZone' : undeclared identifier

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(59) : error C2228: left of '.TrimLeft' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(60) : error C2228: left of '.Isvalidate' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(70) : error C2065: 'm_ComboBox' : undeclared identifier

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(70) : error C2228: left of '.FindStringExact' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(75) : error C2228: left of '.SetItemDataPtr' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(82) : error C2228: left of '.FindStringExact' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(84) : error C2228: left of '.GetItemDataPtr' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(87) : error C2228: left of '.SetItemDataPtr' must have class/struct/union type

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(91) : error C2601: 'OnSelchangeCombo1' : local function definitions are illegal

D:\建立檔案夾\Ex_CityCode2\CityZoneDlg.cpp(105) : error C2601: 'OnDestroy' : local function definitions are illegal

執行 cl.exe 時出錯.

I'm new,what's the matter with it? look for help........