Archived

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

Crypthor

MFC TreeView Control

Recommended Posts

Crypthor    122
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
Nypyren    12063

  
// 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