Mackz(在相互) 能留下qq吗?

解决方案 »

  1.   

    好像treectrl,dialogbar等想在单文档分割视图中显示的话要用到TabCtrl新建个视图可不可以直接在单文档分割视图的左视图中新建个tree控件,并且此控件能触发事件等!!!!
    或者加我qq  23145250
      

  2.   

    建议你用向导建立资源样式的程序框架,最后一布右面的视图基类不要选择CListView,而是自己需要的比如CFormView。
      

  3.   

    Mackz(在相互) 能给我个完整的例子吗?
    我是个菜鸟
      

  4.   

    现在已经成功在单文档分割视图的左视图中新建了tree控件,并加载了
    但不知此控件的事件怎么接受,我贴一部分代码谁帮我看看
    IMPLEMENT_DYNCREATE(MyTree, CFormView)MyTree::MyTree()
    : CFormView(MyTree::IDD)
    {
    //{{AFX_DATA_INIT(MyTree)
    // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
    }MyTree::~MyTree()
    {
    }void MyTree::DoDataExchange(CDataExchange* pDX)
    {
    CFormView::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(MyTree)
    DDX_Control(pDX, IDC_MY_TREE, m_tree);
    //}}AFX_DATA_MAP
    }
    BEGIN_MESSAGE_MAP(MyTree, CFormView)
    //{{AFX_MSG_MAP(MyTree)
    ON_WM_LBUTTONDBLCLK()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // MyTree diagnostics#ifdef _DEBUG
    void MyTree::AssertValid() const
    {
    CFormView::AssertValid();
    }void MyTree::Dump(CDumpContext& dc) const
    {
    CFormView::Dump(dc);
    }
    #endif //_DEBUG
    /////////////////////////////////////////////////////////////////////////////void MyTree::OnInitialUpdate() 
    {
    CFormView::OnInitialUpdate();

    SetIcon(m_hIcon, TRUE); // Set big icon
    SetIcon(m_hIcon, FALSE); HTREEITEM hItem1A=m_tree.InsertItem(_T("前处理"),0,1);
    m_tree.InsertItem(_T("模型"),0,1,hItem1A,TVI_LAST);

    HTREEITEM hItem2_1B=m_tree.InsertItem(_T("LAYER2_1B"),0,1,hItem1A,TVI_LAST);
    m_tree.InsertItem(_T("LAYER3_1A"),0,1,hItem2_1B);
    m_tree.InsertItem(_T("LAYER3_1B"),0,1,hItem2_1B);
    m_tree.InsertItem(_T("LAYER3_1C"),0,1,hItem2_1B);
        m_tree.InsertItem(_T("LAYER2_1C"),0,1,hItem1A,TVI_LAST); HTREEITEM hItem1B=m_tree.InsertItem(_T("计算"),0,1);
        m_tree.InsertItem(_T("LAYER2_2A"),0,1,hItem1B,TVI_LAST);
        m_tree.InsertItem(_T("LAYER2_2B"),0,1,hItem1B,TVI_LAST);
        m_tree.InsertItem(_T("LAYER2_2C"),0,1,hItem1B,TVI_LAST);
    }void MyTree::OnLButtonDblClk(UINT nFlags, CPoint point) 
    {
    m_hTreeItem = m_tree.GetSelectedItem();
    CString S1 = m_tree.GetItemText(m_hTreeItem);
    AfxMessageBox("You have selected "+S1);
    }
    头文件中:
    class MyTree : public CFormView
    {
    protected:
    MyTree();           // protected constructor used by dynamic creation
    DECLARE_DYNCREATE(MyTree)// Form Data
    public:
    //{{AFX_DATA(MyTree)
    enum { IDD = IDD_MY_TREE };
    CTreeCtrl m_tree;
    //}}AFX_DATA// Attributes
    public:
    HTREEITEM m_hTreeItem;
    HICON m_hIcon;
    // Operations
    public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(MyTree)
    public:
    virtual void OnInitialUpdate();
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL// Implementation
    protected:
    virtual ~MyTree();
    #ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
    #endif // Generated message map functions
    //{{AFX_MSG(MyTree)
    afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };或者加我qq  23145250
      

  5.   

    你要例子,不是告诉你了,向导生成的例子,左半部分从CTreeView继承的,还要自己用CFormView再贴一个TreeCtrl干吗?
      

  6.   

    终于搞定了,以上各楼的回答都没用上,只是因为我把消息的来源搞错了
    不应接受MyTree::OnLButtonDblClk
    而因该是MyTree::OnDblclkMyTree消息还是谢谢各位了