Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hello,
 
Did anybody did the multiple selection in the tree control
using win32..
 
i stucked here for multiple selection
 
i have only winProc of tree control so how to handle
in it
 
Please reply its very urgent basis
 
Smile | :)
 
Many thanks
.
Posted 7-Oct-12 21:00pm
Comments
Sergey Alexandrovich Kryukov at 8-Oct-12 3:23am
   
Is that really a question? Then the answer is: yes many did it. Do you need the answer for all the languages and libraries you listed? --SA
enhzflep at 8-Oct-12 4:11am
   
See here: <a title="open in new window" target="new window" href="http://www.whathaveyoutried.com">how to solve multi-select problem</a>
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

For Win32 API
ctrlTree.Create(WS_CHILD|TVS_HASBUTTONS|TVS_CHECKBOX|, ctrlRect, this, IDC_TREECTRL);
Then check notification of NM_CLICK event
case NM_CLICK:
{
    POINT cursorPos; GetCursorPos(&cursorPos);
    ScreenToClient(hwndTree, &cursorPos);
    TVHITTESTINFO thinf;
    thinf.pt = cursorPos;
    TreeView_HitTest(hwndTree, &thinf);
    if (thinf.flags == TVHT_ONITEMSTATEICON)
    {
        //state changed: check the state of the item under the cursor
        BOOL isChecked = TreeView_GetCheckState(hwndTree, thinf.hItem);
        if (isChecked)
        // do something
        else
        // do nothing?
    }
}
break;
 

For MFC
At form designer selectenable the "Check boxes" style on your control.
Then use the following code:
 
DWORD dwLong = m_tree.GetWindowLong(GWL_EXSTYLE);
dwLong |= TVS_CHECKBOXES;
m_tree.SetWindowLong(GWL_EXSTYLE, dwLong);
  Permalink  
Comments
Ram Shelke at 8-Oct-12 7:00am
   
Hey Thanks for Quick reply, i dont want to use checkboxes insted of selection only
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If you can use WTL CTreeViewCtrl.
for more details-
TreeCtrl - A WTL tree control with Windows Vista style item selection[^]
 
thanks.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 696
1 OriginalGriff 478
2 Tadit Dash 400
3 sanket saxena 337
4 Peter Leow 228
0 Sergey Alexandrovich Kryukov 11,890
1 OriginalGriff 7,335
2 Peter Leow 5,003
3 Abhinav S 3,943
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web03 | 2.8.140421.2 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid