Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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

:)

Many thanks
.
Posted
Comments
Sergey Alexandrovich Kryukov 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 8-Oct-12 4:11am    

For Win32 API
C++
ctrlTree.Create(WS_CHILD|TVS_HASBUTTONS|TVS_CHECKBOX|, ctrlRect, this, IDC_TREECTRL);

Then check notification of NM_CLICK event
C++
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:

C++
DWORD dwLong = m_tree.GetWindowLong(GWL_EXSTYLE);
dwLong |= TVS_CHECKBOXES;
m_tree.SetWindowLong(GWL_EXSTYLE, dwLong);
 
Share this answer
 
Comments
Ram Shelke 8-Oct-12 7:00am    
Hey Thanks for Quick reply,

i dont want to use checkboxes insted of selection only
If you can use WTL CTreeViewCtrl.
for more details-
TreeCtrl - A WTL tree control with Windows Vista style item selection[^]

thanks.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900