Sophie
April 30th, 1999, 02:19 PM
Why am I getting this error? How can I access w_wndSnap within the CMainToolBar from the CMainframe
Thank You
Cmci &CMainFrame::GetMciCtrl()
{
return CMainToolBar.m_wndSnap;
}
class CMainToolBar : public CToolBar
{
public:
CMainToolBar();
public:
Cmci m_wndSnap;
public:
virtual ~CMainToolBar();
protected:
//{{AFX_MSG(CMainToolBar)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void ActivateFrame(int nCmdShow = -1);
//}}AFX_VIRTUAL
// Implementation
public:
Cmci &GetMciCtrl();
CReponseFilterTab & GetFilterTab();
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CMainToolBar m_wndToolBar; //use to be CToolBar
// Generated message map functions
protected:
CSplitterWnd m_wndSplitter;
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CReponseFilterTab m_filtertab;
};
void CVRSessionView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
CFrameWnd* pFrame= GetParentFrame();
if( pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) {
CMainFrame *pMainFrame= (CMainFrame *)pFrame;
vector<File> list;
CListCtrl &ctlList = GetListCtrl();
int index= ctlList.GetNextItem( -1, LVNI_SELECTED);
while( index >= 0) {
CObject *pObject= (CObject *) ctlList.GetItemData( index);
if( pObject != NULL && pObject->IsKindOf( RUNTIME_CLASS(CFileInfo))){
CFileInfo *pFileInfo= (CFileInfo *) pObject;
list.push_back( pFileInfo->GetFileInfo());
}
index= ctlList.GetNextItem( index, LVNI_SELECTED);
}
if(list.size() == 1){
Cmci &mciCtrl= pMainFrame->GetMciCtrl();
mciCtrl.SetCommand( "close");
mciCtrl.SetDeviceType( "WaveAudio");
CString fileToPlay = (ToCString(list[0]));
ASSERT( Path( ToString( fileToPlay)).IsFile());
mciCtrl.SetFileName(fileToPlay);
mciCtrl.SetCommand("open");
}
}
*pResult = 0;
}
K:\projet2\VRUtilities\MainFrm.cpp(214) : error C2275: 'CMainToolBar' : illegal use of this type as an expression
k:\projet2\vrutilities\maintoolbar.h(14) : see declaration of 'CMainToolBar'
Thank You
Cmci &CMainFrame::GetMciCtrl()
{
return CMainToolBar.m_wndSnap;
}
class CMainToolBar : public CToolBar
{
public:
CMainToolBar();
public:
Cmci m_wndSnap;
public:
virtual ~CMainToolBar();
protected:
//{{AFX_MSG(CMainToolBar)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void ActivateFrame(int nCmdShow = -1);
//}}AFX_VIRTUAL
// Implementation
public:
Cmci &GetMciCtrl();
CReponseFilterTab & GetFilterTab();
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CMainToolBar m_wndToolBar; //use to be CToolBar
// Generated message map functions
protected:
CSplitterWnd m_wndSplitter;
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CReponseFilterTab m_filtertab;
};
void CVRSessionView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
CFrameWnd* pFrame= GetParentFrame();
if( pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) {
CMainFrame *pMainFrame= (CMainFrame *)pFrame;
vector<File> list;
CListCtrl &ctlList = GetListCtrl();
int index= ctlList.GetNextItem( -1, LVNI_SELECTED);
while( index >= 0) {
CObject *pObject= (CObject *) ctlList.GetItemData( index);
if( pObject != NULL && pObject->IsKindOf( RUNTIME_CLASS(CFileInfo))){
CFileInfo *pFileInfo= (CFileInfo *) pObject;
list.push_back( pFileInfo->GetFileInfo());
}
index= ctlList.GetNextItem( index, LVNI_SELECTED);
}
if(list.size() == 1){
Cmci &mciCtrl= pMainFrame->GetMciCtrl();
mciCtrl.SetCommand( "close");
mciCtrl.SetDeviceType( "WaveAudio");
CString fileToPlay = (ToCString(list[0]));
ASSERT( Path( ToString( fileToPlay)).IsFile());
mciCtrl.SetFileName(fileToPlay);
mciCtrl.SetCommand("open");
}
}
*pResult = 0;
}
K:\projet2\VRUtilities\MainFrm.cpp(214) : error C2275: 'CMainToolBar' : illegal use of this type as an expression
k:\projet2\vrutilities\maintoolbar.h(14) : see declaration of 'CMainToolBar'