Archived

This topic is now archived and is closed to further replies.

MFC TreeView Control

This topic is 5537 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys! I have a veeeery big problem. I''m writting a win32 application, but this application is not using MFC. There is a window with child window (richEdit control). I need one more window TreeView, how i can use it ? or how i can create it without using MFC. In general, there is MFC classes, it is possible to use some controls without MFC (afx.h and etc...) ? Pleeease help!

Share this post


Link to post
Share on other sites

  
// I don''t remember if you need to InitCommonControls() or not


// Creating a child treeview window with a static (1 pixel wide) "sunken" edge.

HWND tv = CreateWindowEx(WS_EX_STATICEDGE, WC_TREEVIEW, "",
WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT |
WS_VISIBLE, 0,0,0,0, parent, NULL, ghInstance, 0);


// One of my functions -- Inserts treeview items.


HTREEITEM TV_InsItem(HWND tv, HTREEITEM phti, char *string, int image, void *extra)
{
TVINSERTSTRUCT tvis;

tvis.hParent = phti;
tvis.hInsertAfter = (phti)?TVI_SORT:TVI_ROOT;
tvis.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
tvis.item.pszText = string;
tvis.item.cchTextMax = strlen(string)+1;
tvis.item.iImage = image;
tvis.item.iSelectedImage = image;
tvis.item.lParam = (LPARAM)extra;

return TreeView_InsertItem(tv, &tvis);
}

// If you want images in your treeview (the icons to the left of the item text, you will need to check out image lists.


Share this post


Link to post
Share on other sites