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. Node selection problem

Node selection problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 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 In my app I have a treeview with some nodes. I want to select one of them and it will be highlighted. The problem is that I don`t get highlighted neither selected. This is my code to select a node: [Code] case WM_NOTIFY: { LPNMHDR notifyMessageStruct = (LPNMHDR)lParam; if(notifyMessageStruct->hwndFrom == treeViewHwnd) { if(notifyMessageStruct->code == NM_CLICK) { nodeSelected = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_TREE1, TVM_GETNEXTITEM, TVGN_CARET, (LPARAM)nodeSelected); if(nodeSelected == NULL)MessageBox(NULL, "", "", MB_OK); TreeView_EnsureVisible(hwnd, nodeSelected); SendDlgItemMessage(hwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_CARET, (LPARAM)nodeSelected); SendDlgItemMessage(hwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_DROPHILITE, 0); } } break; } [/Code] My code to create the treeview: [Code] treeViewHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_TRACKSELECT|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 400, myRect.bottom, hwnd, (HMENU)IDC_TREE1, hCurrentInstance, NULL); [/Code] Someone can helps? Thanks again

    A 1 Reply Last reply
    0
    • A Alex Cutovoi

      Hi fellows In my app I have a treeview with some nodes. I want to select one of them and it will be highlighted. The problem is that I don`t get highlighted neither selected. This is my code to select a node: [Code] case WM_NOTIFY: { LPNMHDR notifyMessageStruct = (LPNMHDR)lParam; if(notifyMessageStruct->hwndFrom == treeViewHwnd) { if(notifyMessageStruct->code == NM_CLICK) { nodeSelected = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_TREE1, TVM_GETNEXTITEM, TVGN_CARET, (LPARAM)nodeSelected); if(nodeSelected == NULL)MessageBox(NULL, "", "", MB_OK); TreeView_EnsureVisible(hwnd, nodeSelected); SendDlgItemMessage(hwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_CARET, (LPARAM)nodeSelected); SendDlgItemMessage(hwnd, IDC_TREE1, TVM_SELECTITEM, TVGN_DROPHILITE, 0); } } break; } [/Code] My code to create the treeview: [Code] treeViewHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_TRACKSELECT|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 400, myRect.bottom, hwnd, (HMENU)IDC_TREE1, hCurrentInstance, NULL); [/Code] Someone can helps? Thanks again

      A Offline
      A Offline
      Ali Rafiee
      wrote on last edited by
      #2

      Not really sure what you are trying to do there. But maybe the tree doesn't have the focus and that's why you are not seeing the selection. Add this TVS_SHOWSELALWAYS to the flags when you are creating the tree to see if that helps. AliR. Visual C++ MVP

      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