在TreeCtrl控件中,加入了checkbox的风格。那当我在checkbox 中打勾时会引发什么消息呀?

解决方案 »

  1.   

    我怎么才能知道在哪一个checkbox中打了勾?
      

  2.   

    1.CTreeCtrl::GetSelectedItem2。再判断选择是哪一个
      

  3.   

    其实我的意思是当我给一个checkbox打勾时,会触发一个消息,那这个消息是什么呀?
      

  4.   

    你处理一下该控件的WM_LBUTTONDOWN消息,再用HitTest就可以知道用户选择了哪一项了。
    example:
    UINT uFlags;
    HTREEITEM hItem = pmyTreeCtrl->HitTest(myPoint, &uFlags);if ((hItem != NULL) && (TVHT_ONITEM & uFlags))
    {
       pmyTreeCtrl->Select(hItem, TVGN_CARET);
    }
    uFlags可以是:
    TVHT_ABOVE  Above the client area.  
    TVHT_BELOW  Below the client area.  
    TVHT_NOWHERE  In the client area, but below the last item.  
    TVHT_ONITEM  On the bitmap or label associated with an item.  
    TVHT_ONITEMBUTTON  On the button associated with an item.  
    TVHT_ONITEMICON  On the bitmap associated with an item.  
    TVHT_ONITEMINDENT  In the indentation associated with an item.  
    TVHT_ONITEMLABEL  On the label (string) associated with an item.  
    TVHT_ONITEMRIGHT  In the area to the right of an item.  
    TVHT_ONITEMSTATEICON  On the state icon for a tree-view item that is in a user-defined state.  
    TVHT_TOLEFT  To the left of the client area.  
    TVHT_TORIGHT  To the right of the client area 
    自己看MSDN吧
      

  5.   

    请看我的代码有什么错误。我是在一个基于对话框的程序中做的LRESULT CDialogBaseDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
    {
    switch(message)
    {
    case WM_NOTIFY:
    {
    LPNMHDR lpnmh = (LPNMHDR) lParam;
    TVHITTESTINFO ht = {0};

    if((lpnmh->code  == NM_CLICK) && (lpnmh->idFrom == IDC_TREE))
    {
    DWORD dwpos = GetMessagePos();

    ht.pt.x = GET_X_LPARAM(dwpos);
    ht.pt.y = GET_Y_LPARAM(dwpos);

    MapWindowPoints( this , &ht.pt, 2); m_Tree.HitTest(&ht);

    if(TVHT_ONITEMSTATEICON & ht.flags)
    {
    PostMessage( UM_CHECKSTATECHANGE, 0, (LPARAM)ht.hItem);
    }
    }
    }
    break;

    case UM_CHECKSTATECHANGE:
    {
    HTREEITEM   pItem = (HTREEITEM)lParam;
    int j = (int)m_Tree.GetItemData(pItem);
    if(j == 0)
    MessageBox("root is selected !");
    }
    break; 


    }
    return CDialog::WindowProc(message, wParam, lParam);}在if(TVHT_ONITEMSTATEICON & ht.flags)这里,没有进入执行