Click to See Complete Forum and Search --> : Winapi C++ collapse all nodes on creation


zaryk
September 29th, 2008, 06:05 PM
I know to do this probably requires TVIS_EXPANDED but not sure exactly how to set it up right.


void CreateTreeview(HWND hwnd)
{
//Treeview Control
TV_INSERTSTRUCT tvinsert;
HTREEITEM Parent;
HTREEITEM Before;
HTREEITEM Root;

TREEVIEW = CreateWindowEx(WS_EX_LEFT,
WC_TREEVIEW,
NULL,
TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT | TVS_DISABLEDRAGDROP | WS_BORDER |WS_CHILD | WS_VISIBLE,
0,
0,
0,
0,
hwnd,
(HMENU)ID_TREEVIEW,
hInst,
NULL);

tvinsert.hParent=NULL;
tvinsert.hInsertAfter=TVI_ROOT;
tvinsert.item.mask=TVIF_TEXT;
tvinsert.item.pszText="Project -";
Parent=(HTREEITEM)SendDlgItemMessage(hwnd,ID_TREEVIEW,
TVM_INSERTITEM,0,(LPARAM)&tvinsert);

....
.....
}

kirants
September 29th, 2008, 06:54 PM
Sorry. It isn't clear what you are trying to achieve, is it collapsing or expanding ?

zaryk
September 29th, 2008, 07:28 PM
Now that I think about it, im kinda confused myself...I think im trying to expand it.....yeah yeah....i dont know what i was thinking.

kirants
September 29th, 2008, 07:41 PM
Tried this after inserting item ?

http://msdn.microsoft.com/en-us/library/bb773568(VS.85).aspx

zaryk
September 29th, 2008, 08:50 PM
Parent=(HTREEITEM)SendMessage(TREEVIEW, TVM_EXPAND,TVE_EXPAND,(LPARAM)&tvinsert);

and TVE_EXPANDPARTIAL doesnt work....brings up an error that it is undeclared

I inserted this after the first parent node, and it expanded it, but got rid fo the [+] [-] symbol....so in effect it looked like a child node....nothing else has done anything.

Marc G
September 30th, 2008, 09:20 AM
the LPARAM in that call should be a HTREEITEM of the parent that you want to expand, not a tvinsert.

zaryk
September 30th, 2008, 10:25 PM
Apparently, whatever I put in the place of &tvinsert, it either displays everything expanded (look all like child nodes) or does nothing at all....based on msdn definition of expandpartial...that is what i am looking for but like i said it doesnt work.