当自己调用BOOL Expand( HTREEITEM hItem, UINT nCode )时,第一次会响应OnItemexpanded(),但是,对一个已经展开过的Item使用Expand(),就不再会响应OnItemexpanded()(即使 SetItemState(hItem, UINT(~TVIS_EXPANDED), UINT(TVIS_EXPANDED));
SetItemState(hItem, UINT(~TVIS_EXPANDEDONCE), UINT(TVIS_EXPANDEDONCE));
SetItemState(hItem, UINT(~TVIS_EXPANDPARTIAL), UINT(TVIS_EXPANDPARTIAL));)希望大侠不啬赐教,如何每次调用Expand(),都会响应OnItemexpanded().

解决方案 »

  1.   

    TVN_ITEMEXPANDED
    消息只会在展开或者收缩节点时才会被激发,如果没有任何展开或收缩动作,该通知不会激发
      

  2.   

    自己从CTreeCtrl继承,重载OnItemexpanded试试
      

  3.   

    对一个已经展开过的Item使用Expand(),就不再会响应OnItemexpanded(),这个是正常的啊,TVN_ITEMEXPANDED
    消息只会在展开或者收缩节点时才会被激发,如果没有任何展开或收缩动作,该通知不会激发
      

  4.   

    不好意思没说清楚,1、对一个节点使用Expand(),OnItemexpanded()被响应;2、用鼠标点击此节点,将其收缩;3、再调用Expand(),则OnItemexpanded()不响应。When an item is first expanded , a TVM_EXPAND message generates TVN_ITEMEXPANDING and TVN_ITEMEXPANDED notification messages and the item's TVIS_EXPANDEDONCE state flag is set. As long as this state flag remains set, subsequent TVM_EXPAND messages will not generate TVN_ITEMEXPANDING or TVN_ITEMEXPANDED notifications. To reset the TVIS_EXPANDEDONCE state flag, send a TVM_EXPAND message with the TVE_COLLAPSE and TVE_COLLAPSERESET flags set. The expand operation may fail if the owner of the treeview control denies the operation in response to a TVN_ITEMEXPANDING notification.但是用了Expand(hItem, TVE_COLLAPSE)还是没用。
    Why???
      

  5.   

    SetItemState(hItemT, UINT(~TVIS_EXPANDEDONCE), UINT(TVIS_EXPANDEDONCE));
    虽然MSDN说会导致unpredictable result,但好像可以用,我也只有这个办法了。