我做的是将视图分割成两个窗口,一个LISTVIEW,一个FORMVIEW,是想单击某LISTVIEW的某一行,将信息在FORMVIEW的EDIT里显示出来,视图间怎样通信呢?麻烦说详细点,我是菜鸟啊

解决方案 »

  1.   

    当然是通过指针了,
    那边定义一个实现的函数,这边通过那边的视图指针调用该函数显示数据!在创建窗口的时候你就把该指针保存到框架中就可以了,你就可以在任何时候方便的得到该指针了通过得到框架窗口指针函数MFC的
      

  2.   

    应该是通过共有的文档类,这样比较正规,所有的变化先反映到文档类,然后再根据这个去调整其他视图,updateallviews().
      

  3.   

    问题是CLISTCTRL的一行有四个数值,怎么全传过去呢?
      

  4.   

    非常感谢楼上给我的代码,有一点不解,请您指教!
    NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
    int nSelItem = pNMListView->iItem;NM_LISTVIEW 是什么?
      

  5.   

    FROM MSDN:NMLISTVIEW
    typedef struct tagNMLISTVIEW{
        NMHDR   hdr;
        int     iItem;
        int     iSubItem;
        UINT    uNewState;
        UINT    uOldState;
        UINT    uChanged;
        POINT   ptAction;
        LPARAM  lParam;
    } NMLISTVIEW, FAR *LPNMLISTVIEW;Contains information about a list view notification message. This structure is the same as the NM_LISTVIEW structure but has been renamed to fit standard naming conventions. hdr 
    NMHDR structure that contains information about this notification message. 
    iItem 
    Identifies the list view item, or -1 if not used. 
    iSubItem 
    Identifies the subitem, or zero if none. 
    uNewState 
    New item state. This member is zero for notification messages that do not use it. 
    uOldState 
    Old item state. This member is zero for notification messages that do not use it. 
    uChanged 
    Set of flags that indicate the item attributes that have changed. This member is zero for notifications that do not use it. Otherwise, it can have the same values as the mask member of the LVITEM structure. 
    ptAction 
    POINT structure that indicates the location at which the event occurred. This member is undefined for notification messages that do not use it. 
    lParam 
    Application-defined 32-bit value of the item. This member is undefined for notification messages that do not use it.
      

  6.   

    应该是在CMainFrame里处理GetListCtrl(),还是在FormView使用GetListCtrl()?
      

  7.   

    无所谓啦,看你的需求,直接在FormView里处理也一样,没什么影响的
      

  8.   

    如果你有好多个view,那可以把处理集中到CMainFrame,然后分发下去,如果就一个FormView,那以它为主也没什么,CMainFrame也就不重要了
      

  9.   

    十分感谢Elysium的帮助,问题解决了,好开心啊!