Treeview - TreeView_GetItem()

This is a discussion on Treeview - TreeView_GetItem() within the Windows Programming forums, part of the Platform Specific Boards category; Hi, im trying to handle the Tree-views NM_DBLCLK message, to display the name of the D Clicked item: Code: LRESULT ...

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    375

    Treeview - TreeView_GetItem()

    Hi, im trying to handle the Tree-views NM_DBLCLK message, to display the name of the D Clicked item:

    Code:
    LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
    {
     TVITEM tv;
     HWND hwndTree;
     char msg[MAX_PATH];
     int err;
    	
     switch(Msg)
     {
     ...
     case WM_NOTIFY:
      switch(((LPNMHDR) lParam)->code)
      {
       case NM_DBLCLK:
        hwndTree = GetDlgItem(hWndDlg, IDTREE);
        err =TreeView_GetItem(hwndTree,&tv);
        strcpy(msg, "You DCliked on ");
        strcat(msg, tv.pszText);
        MessageBox(NULL,msg, "MSG",MB_OK);
      }
     break;
     ...
    }
    But tv.pszText returns nothing and err gets zeroed. Please help to fix it.
    Thanx.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    329
    Before you run TreeView_GetItem() you have to fill in the tv struct:
    Code:
    	TVHITTESTINFO hti;
    	POINT p1;
    	char achBuf[100];
    
    	GetCursorPos(&p1);
    	hti.flags=TVHT_ONITEM;
    	memcpy(&hti.pt, &p1, sizeof(POINT));
    	ScreenToClient(hwndTree, &hti.pt);
    
    	ZeroMemory(&tv, sizeof(TVITEM));
    	tv.hItem=(HTREEITEM)TreeView_HitTest(hwndTree, &hti);
    	tv.cchTextMax=100;
    	tv.pszText=achBuf;
    	tv.mask=TVIF_TEXT|TVIF_HANDLE;
    	TreeView_GetItem(hwndTree,&tv)
    Last edited by knutso; 05-26-2005 at 01:30 PM.

  3. #3
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    375
    Thanx
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drag & Drop using TreeView
    By Devils Child in forum C# Programming
    Replies: 1
    Last Post: 03-24-2009, 07:02 AM
  2. How can I list processes in a treeview?
    By hileci555 in forum Windows Programming
    Replies: 0
    Last Post: 07-21-2008, 04:22 AM
  3. TreeView and Database
    By x64 in forum C# Programming
    Replies: 2
    Last Post: 01-14-2007, 06:42 PM
  4. Treeview Custom Draw
    By mobazr in forum Windows Programming
    Replies: 1
    Last Post: 06-21-2005, 02:51 AM
  5. Problem showing item in TreeView
    By Garfield in forum Windows Programming
    Replies: 4
    Last Post: 03-18-2004, 12:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21