CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 1999
    Posts
    121

    Need help with this code

    What I'm trying to accomplish is to find the selected Item and make sure it's a file not a directory. And if it's a file I get control of the Multimedia control to paly the wave file selected.

    What am I doing wrong? If you require more info let me know

    Thank you in advance

    void CVRSessionView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
    {
    NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
    CFrameWnd* pFrame= GetParentFrame();
    if( pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) {
    CListCtrl &ctlList = GetListCtrl();
    CObject *pObject= (CObject *) ctlList.GetItemData( pNMListView->iItem); //ASSERT ERROR HERE
    if(pObject->IsKindOf(RUNTIME_CLASS(CFileInfo))){
    Cmci mci; //Multimedia control
    mci.SetDeviceType("WaveAudio");
    //mci.SetFileName(fileToPlay);
    mci.SetCommand("open");
    }

    }

    class CFileInfo ublic CObject
    {
    public:
    void SetFileInfo(File &fileInfo);
    File GetFileInfo();
    CFileInfo();
    virtual ~CFileInfo();
    DECLARE_DYNAMIC (CFileInfo);

    private:
    File m_fileInfo;
    };

    CFileInfo::CFileInfo()
    {

    }

    CFileInfo::~CFileInfo()
    {

    }

    File CFileInfo::GetFileInfo()
    {
    return m_fileInfo;
    }

    void CFileInfo::SetFileInfo(File &fileInfo)
    {
    m_fileInfo = fileInfo;
    }



    *pResult = 0;
    }



  2. #2
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: Need help with this code

    What is it that is not working?

    sally


  3. #3
    Join Date
    Apr 1999
    Posts
    121

    Re: Need help with this code

    Look for if(list.size() == 1)

    I need to get the multimedia control i've created in the CMainFrame::OnCreate
    The code for the multimedia start with "#define SNAP_WIDTH 389"

    How do I go from the view to the mainframe?

    Thanks in advance

    void CVRSessionView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
    {
    NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
    vector<HTREEITEM> list;
    CFrameWnd* pFrame= GetParentFrame();
    if( pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) {
    CListCtrl &ctlList = GetListCtrl();
    int index= ctlList.GetNextItem( -1, LVNI_SELECTED);
    while( index >= 0) {
    CObject *pObject= (CObject *) ctlList.GetItemData( index);
    HTREEITEM hTreeItem= (HTREEITEM) ctlList.GetItemData( index);
    if( pObject != NULL )
    list.push_back( hTreeItem);
    index= ctlList.GetNextItem( index, LVNI_SELECTED);

    }
    if(list.size() == 1){



    }

    }

    *pResult = 0;
    }

    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
    return -1;

    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1; // fail to create
    }
    m_filtertab.Create(this,IDD_Filtertab,CBRS_TOP,1111);


    if (!m_wndStatusBar.Create(this) ||
    !m_wndStatusBar.SetIndicators(indicators,
    sizeof(indicators)/sizeof(UINT)))
    {
    TRACE0("Failed to create status bar\n");
    return -1; // fail to create
    }

    // TODO: Delete these three lines if you don't want the toolbar to
    // be dockable
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    m_filtertab.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar);
    DockControlBar(&m_filtertab);
    ///Added code


    #define SNAP_WIDTH 389 //the width of the Multimedia
    //set up the Multimedia control as a snap mode select box //
    //First get the index of the placeholder's position in the toolbar
    int index = 0;
    CRect rect;
    while(m_wndToolBar.GetItemID(index)!=IDP_PLACEHOLDER2) index++;
    //next convert that button to a seperator and get its position
    m_wndToolBar.SetButtonInfo(index, IDP_PLACEHOLDER2, TBBS_SEPARATOR, SNAP_WIDTH);
    m_wndToolBar.GetItemRect(index, &rect);

    // then .Create the multimedia control and show it

    if (!m_wndToolBar.m_wndSnap.Create(NULL,WS_CHILD|WS_VISIBLE,rect, &m_wndToolBar, IDP_PLACEHOLDER2))
    {
    TRACE0("Failed to create Multimedia Control\n");
    return FALSE;
    }
    m_wndToolBar.m_wndSnap.ShowWindow(SW_SHOW);
    m_wndToolBar.m_wndSnap.SetEjectVisible(FALSE);
    m_wndToolBar.m_wndSnap.SetRecordVisible(FALSE);
    m_wndToolBar.m_wndSnap.SetPrevVisible(FALSE);
    m_wndToolBar.m_wndSnap.SetNextVisible(FALSE);
    m_wndToolBar.m_wndSnap.SetEnabled(TRUE);
    m_wndToolBar.m_wndSnap.SetAutoEnable(TRUE);
    m_wndToolBar.m_wndSnap.SetCommand("close");


    return 0;
    }
    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:

    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;

    };
    class CMainToolBar : public CToolBar
    {
    // Construction
    public:
    CMainToolBar();

    // Attributes
    public:
    Cmci m_wndSnap;
    // Operations
    public:

    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CMainToolBar)
    //}}AFX_VIRTUAL

    // Implementation
    public:
    virtual ~CMainToolBar();

    // Generated message map functions
    protected:
    //{{AFX_MSG(CMainToolBar)
    // NOTE - the ClassWizard will add and remove member functions here.
    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()
    };



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured