1

解决方案 »

  1.   

    请问高手们:这样使用WM_NOTITY 捕获树形控件的消息,为什么不正确。。感谢~!
                case WM_NOTIFY:  //如果消息是WM_NOTIFY
                {   
                    NMHDR *nhr;
                    nhr = (NMHDR *)cwps.lParam;
                    NM_TREEVIEW *ntv =(NM_TREEVIEW *)nhr;   //转换为大数据结构
                    if (ntv->action == TVN_SELCHANGING ||ntv->action == TVN_SELCHANGED)
                    {
                                ...........    //这里怎么样都进不来。。这是为什么?
                    }另外:捕获树形控件的操作消息,是用TVN_XXX的通知消息好,,还是用TVM_控件消息好???
      

  2.   

    A tree control (CTreeCtrl) sends the following notification messages as WM_NOTIFY messages:Notification message
     Description
     
    TVN_BEGINDRAG
     Signals the start of a drag-and-drop operation
     
    TVN_BEGINLABELEDIT
     Signals the start of in-place label editing
     
    TVN_BEGINRDRAG
     Signals the start of a drag-and-drop operation, using the right mouse button
     
    TVN_DELETEITEM
     Signals the deletion of a specific item
     
    TVN_ENDLABELEDIT
     Signals the end of label editing
     
    TVN_GETDISPINFO
     Requests information that the tree control requires to display an item
     
    TVN_ITEMEXPANDED
     Signals that a parent item's list of child items was expanded or collapsed
     
    TVN_ITEMEXPANDING
     Signals that a parent item's list of child items is about to be expanded or collapsed
     
    TVN_KEYDOWN
     Signals a keyboard event
     
    TVN_SELCHANGED
     Signals that the selection has changed from one item to another
     
    TVN_SELCHANGING
     Signals that the selection is about to be changed from one item to another
     
    TVN_SETDISPINFO
     Notification to update the information maintained for an item
     
      

  3.   

    NM_TREEVIEW*?是WINDOWS CE的?nhr = (NMHDR *)cwps.lParam;
    看你代码象是WIN API的,但是这个cwps是什么东东?
    WIN API代码应该是这样的:case WM_NOTIFY:  //如果消息是WM_NOTIFY 
    {  
       LPNMTREEVIEW nhr = (LPNMTREEVIEW)lParam; 
       if (nhr->hdr->code == TVN_SELCHANGING || nhr->hdr->code == TVN_SELCHANGED) 
       { 
           //这里应该能进来
       }
       ... 
      

  4.   

    谢谢楼上的解答。本质上,,你的代码和我所使用的是一样的。。只是我多转换了一次。
    LPNMTREEVIEW 与NM_TREEVIEW *
    是同一个结构体。用你的方法也是一样没有捕获到Tree的动作。~~~~~
      

  5.   

    你最好说清楚一些,比如case WM_NOTIFY能进去吗?你的这段代码在哪里?树控件是如何设计的?