Click here to Skip to main content
11,478,642 members (64,812 online)
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 22: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
   
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 209
1 F-ES Sitecore 170
2 Frankie-C 120
3 OriginalGriff 105
4 DamithSL 95
0 Sergey Alexandrovich Kryukov 7,865
1 OriginalGriff 7,341
2 Sascha Lefèvre 3,059
3 Maciej Los 2,491
4 Richard Deeming 2,335


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100