Treeview creation problem
-
Hi fellows I`m trying to create a treeview in my app but I don`t have any sucess. I`ve read the Microsoft article [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/treeview.asp\[/url\] and I`ve tried to do something like that. The problem is that whem I create a node in a function that I created it returns NULL. I think that my code is right, so what`s going on?? Thanks for the support. Below is my code? I created my treeview like this:
treeViewHwnd = CreateWindowEx(WS_EX_LEFT, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 150, 600, hwnd, NULL, hCurrentInstance, NULL);
treeViewHwnd is a global HWND. In this part I want to put a node in the treeviewcase WM_CHAR: { switch(wParam) { case 'a': { InitCommonControls(); treeViewHwnd = GetDlgItem(hwnd, IDC_TREE1); OpenedWindows(GetForegroundWindow()); for(int i = 0 ; i < sNameHwnds.size() ; i++) { InsertNodeInTV(hwnd, sNameHwnds[i], 1); MessageBox(NULL, sNameHwnds[i].c_str(), "", MB_OK); break; } break; } .....
And here I create the node:#define IDC_TREE1 10 HTREEITEM InsertNodeInTV(HWND tvHwnd, string sNodeName, int iLevel) { static HTREEITEM ParentItem, BeforeItem, RootItem; ParentItem = (HTREEITEM)TVI_FIRST; BeforeItem = RootItem = NULL; TVINSERTSTRUCT treeViewInsert; treeViewInsert.item.mask = TVIF_TEXT; treeViewInsert.item.pszText = (char*)sNodeName.c_str(); treeViewInsert.item.cchTextMax = sizeof(treeViewInsert.item.pszText)/treeViewInsert.item.pszText[0]; treeViewInsert.hInsertAfter = TVI_ROOT; treeViewInsert.hParent = NULL; ParentItem = (HTREEITEM)SendDlg
-
Hi fellows I`m trying to create a treeview in my app but I don`t have any sucess. I`ve read the Microsoft article [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/treeview.asp\[/url\] and I`ve tried to do something like that. The problem is that whem I create a node in a function that I created it returns NULL. I think that my code is right, so what`s going on?? Thanks for the support. Below is my code? I created my treeview like this:
treeViewHwnd = CreateWindowEx(WS_EX_LEFT, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 150, 600, hwnd, NULL, hCurrentInstance, NULL);
treeViewHwnd is a global HWND. In this part I want to put a node in the treeviewcase WM_CHAR: { switch(wParam) { case 'a': { InitCommonControls(); treeViewHwnd = GetDlgItem(hwnd, IDC_TREE1); OpenedWindows(GetForegroundWindow()); for(int i = 0 ; i < sNameHwnds.size() ; i++) { InsertNodeInTV(hwnd, sNameHwnds[i], 1); MessageBox(NULL, sNameHwnds[i].c_str(), "", MB_OK); break; } break; } .....
And here I create the node:#define IDC_TREE1 10 HTREEITEM InsertNodeInTV(HWND tvHwnd, string sNodeName, int iLevel) { static HTREEITEM ParentItem, BeforeItem, RootItem; ParentItem = (HTREEITEM)TVI_FIRST; BeforeItem = RootItem = NULL; TVINSERTSTRUCT treeViewInsert; treeViewInsert.item.mask = TVIF_TEXT; treeViewInsert.item.pszText = (char*)sNodeName.c_str(); treeViewInsert.item.cchTextMax = sizeof(treeViewInsert.item.pszText)/treeViewInsert.item.pszText[0]; treeViewInsert.hInsertAfter = TVI_ROOT; treeViewInsert.hParent = NULL; ParentItem = (HTREEITEM)SendDlg
-
Hi fellows I`m trying to create a treeview in my app but I don`t have any sucess. I`ve read the Microsoft article [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/treeview.asp\[/url\] and I`ve tried to do something like that. The problem is that whem I create a node in a function that I created it returns NULL. I think that my code is right, so what`s going on?? Thanks for the support. Below is my code? I created my treeview like this:
treeViewHwnd = CreateWindowEx(WS_EX_LEFT, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 150, 600, hwnd, NULL, hCurrentInstance, NULL);
treeViewHwnd is a global HWND. In this part I want to put a node in the treeviewcase WM_CHAR: { switch(wParam) { case 'a': { InitCommonControls(); treeViewHwnd = GetDlgItem(hwnd, IDC_TREE1); OpenedWindows(GetForegroundWindow()); for(int i = 0 ; i < sNameHwnds.size() ; i++) { InsertNodeInTV(hwnd, sNameHwnds[i], 1); MessageBox(NULL, sNameHwnds[i].c_str(), "", MB_OK); break; } break; } .....
And here I create the node:#define IDC_TREE1 10 HTREEITEM InsertNodeInTV(HWND tvHwnd, string sNodeName, int iLevel) { static HTREEITEM ParentItem, BeforeItem, RootItem; ParentItem = (HTREEITEM)TVI_FIRST; BeforeItem = RootItem = NULL; TVINSERTSTRUCT treeViewInsert; treeViewInsert.item.mask = TVIF_TEXT; treeViewInsert.item.pszText = (char*)sNodeName.c_str(); treeViewInsert.item.cchTextMax = sizeof(treeViewInsert.item.pszText)/treeViewInsert.item.pszText[0]; treeViewInsert.hInsertAfter = TVI_ROOT; treeViewInsert.hParent = NULL; ParentItem = (HTREEITEM)SendDlg