Click to See Complete Forum and Search --> : Umm...Whats going on with this?


laiason5
June 2nd, 1999, 08:47 PM
heres the problem:

#if !defined(AFX_MYTREECTRL_H__CE6F240E_0D3E_11D3_853B_004F490685B3__INCLUDED_)
#define AFX_MYTREECTRL_H__CE6F240E_0D3E_11D3_853B_004F490685B3__INCLUDED_

#include <apvector.h>
#include "CPhysicsDBDlg.h" //simply including this file causes massive amounts of errors
//this doesnt make sense as this is my main dlg box in my program


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyTreeCtrl.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CMyTreeCtrl window

struct tNode
{
HTREEITEM NodeName;
apvector<tNode*> SubNodes;
apvector<CString> Q;
apvector<CString> A;
apvector<CString> Dum1;
apvector<CString> Dum2;
apvector<CString> Dum3;
apvector<CString> Dum4;

};

class CMyTreeCtrl : public CTreeCtrl
{
// Construction
public:
CMyTreeCtrl();

// Attributes
public:

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyTreeCtrl)
//}}AFX_VIRTUAL
CPhysicsDBDlg * MyParent;

// Implementation
public:
//CPhysicsDBDlg* MyParentWin;
void DeleteBranch(tNode* pDelNode);

virtual ~CMyTreeCtrl();

// Generated message map functions
protected:
//{{AFX_MSG(CMyTreeCtrl)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYTREECTRL_H__CE6F240E_0D3E_11D3_853B_004F490685B3__INCLUDED_)




anyone know what could cause errors by simply including a file that is compiled fine on its own and runs the program fine if it is not included in any custom made classes?
thanks
L5

Paul Burns
June 2nd, 1999, 10:31 PM
its possible the CPhysicsDBDlg.h file contains declarations which are dependant on other include files.

Paul Burns
June 2nd, 1999, 10:47 PM
wait a minute, i'm guessing you've got something like this happening...


// in "MyTreeCtrl.h"
class CMyTreeCtrl : public CTreeCtrl
{
// ...
//
CPhysicsDBDlg * MyParent;
// ...
//
}

// and in "PhysicsDBDlg.h"
class CPhysicsDBDlg : public CDialog
{
// ...
//
CMyTreeCtrl m_MyTree;
// ...
//
}




if so, then you've got a sort of circular reference happening - you can't in include "MyTreeCtrl.h" without including "PhysicsDBDlg.h" before it, and you can't include "PhysicsDBDlg.h" without including "MyTreeCtrl.h" before, etc., etc. Easy fixed, forward declare one of them...


// add this at the beginning of "MyTreeCtrl.h"
extern class CPhysicsDBDlg;

laiason5
June 2nd, 1999, 11:25 PM
thanks a WHOLE LOT.
what you said...worked.
thanks again.