Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Treeview creation problem

Treeview creation problem

Scheduled Pinned Locked Moved C / C++ / MFC
comhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Cutovoi
    wrote on last edited by
    #1

    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 treeview case 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

    L V 2 Replies Last reply
    0
    • A Alex Cutovoi

      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 treeview case 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

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Besides the fact that "int iLevel" is not used the rest of the code runs correctly when I have good values like tvHwnd, IDC_TREE1, etc. Therefore I suspect one of your values is incorrect.

      1 Reply Last reply
      0
      • A Alex Cutovoi

        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 treeview case 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

        V Offline
        V Offline
        valikac
        wrote on last edited by
        #3

        cchTextMax = sNodeName.size() Kuphryn

        L 1 Reply Last reply
        0
        • V valikac

          cchTextMax = sNodeName.size() Kuphryn

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Wow... how did i miss that :-O

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups