Sign in to follow this  
Sawsan Emam

problem with Tree View Control

Recommended Posts

Hi Everyone, i am using Win32 API and i am using the Tree Controls to show some data contained in some binary file i created ... my problem is the next section of code is work properly ... but when i replace NM_DBLCLK with NM_CLICK ... it return the wrong Tree Node. actually, it returns the previous selected Tree Node ... example: when i select the first Node it gives the error message saying "No Item Selected" then when i choose let's say Node 2 .. it shows the Content of Node 1 .. then when i select Node 4 (for example) it shows the Content of Node 2 and so on ... can anyone tell me where's my mistake ??? case WM_NOTIFY: switch(LOWORD(wParam)) { case IDC_TREE: switch(((LPNMHDR)lParam)->code) { case NM_DBLCLK: { TVITEM tvi; char *Text = NULL; HTREEITEM selected = NULL; selected = (HTREEITEM) SendDlgItemMessage(hWnd, IDC_TREE, TVM_GETNEXTITEM, TVGN_CARET, 0); if(selected == NULL) { MessageBox(hWnd, "NO Item Selected", "Error", MB_OK | MB_ICONERROR); break; } Text = getSelectedFilePath(hWnd, selected); HBITMAP hBmp = getThumbNail(Text); if(hBmp == NULL) SendDlgItemMessage(hMainWindow, IDC_IMAGE, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hNoThumb); else SendDlgItemMessage(hMainWindow, IDC_IMAGE, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmp); SetDlgItemText(hWnd, IDC_EDIT, Text); } break; } break; } break;

Share this post


Link to post
Share on other sites
It probably happens because the double click notification is sent before the selected item actually changes.
Try catching TVN_SELCHANGED notification.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this