class CConfigerDlg : public CDialog
{
// Construction
public:
void SetData(CIpRecord ip,CIpRecord marsk);
int m_button;
CIpRecord m_subNetAdd;
CIpRecord m_IpAddress;
CConfigerDlg(CWnd* pParent = NULL);   // standard constructor// Dialog Data
//{{AFX_DATA(CConfigerDlg)
enum { IDD = IDD_DIALOG2 };
CIPAddressCtrl m_subIp;
CIPAddressCtrl m_Ip;
CStatic m_myStatic4;
CEdit m_name1Class;
CStatic m_secondStatic;
CStatic m_thirdStatic;
CStatic m_firstStatic;
CButton m_myCancel;
CButton m_myOk;
CEdit m_nameClass;
CTabCtrl m_table;
CString m_workgroup;
CString m_name1;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CConfigerDlg)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
protected:
virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected: // Generated message map functions
//{{AFX_MSG(CConfigerDlg)
afx_msg void OnOk();
virtual BOOL OnInitDialog();
afx_msg void OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_CONFIGERDLG_H__5284CBAA_006C_4C09_978A_22139569AFBA__INCLUDED_)
下面是定义的一个函数:
void CConfigerDlg::SetData(CIpRecord ip1, CIpRecord marsk1)
{
m_IpAddress=ip1,m_subNetAdd=marsk1;
   m_Ip.SetAddress(m_IpAddress.m_ip.nField0,m_IpAddress.m_ip.nField1,
m_IpAddress.m_ip.nField2,m_IpAddress.m_ip.nField3);
m_subIp.SetAddress(m_subNetAdd.m_ip.nField0,m_subNetAdd.m_ip.nField1,
m_subNetAdd.m_ip.nField2,m_subNetAdd.m_ip.nField3);
UpdateData(false);
}
在另一个类中声明CConfigerDlg的一个对象例如mm,用mm调用SetData时会出错误。单编译时没有错误

解决方案 »

  1.   

    UpdateData(false);的错。在调用mm.SetData时,对话框窗体如果不存在,则会出现错误。
      

  2.   

    声明了就应该存在了吧!下面是调用过程
    CConfigerDlg m_configer;
    CComputer *tempComputer;
    tempComputer=m_computer.GetComputer(m_cnumber);

    if (tempComputer->m_netCard)
    {
    CIpRecord tempipR,tempsubm;
    tempsubm=tempComputer->m_netCard->m_subnetAdd;
    tempipR=tempComputer->m_netCard->m_address;
    m_configer.SetData(tempipR,tempsubm,tempComputer->m_computerName,
         tempComputer->m_worckgroup);
    }
      

  3.   

    加断点调试,会发现错误在什么地方。
    在调用处,m_configer的窗口还没有显示出来,所以一定会出错。