TreeView_EditLabel() returning NULL

Hey there,
I'm writing an application that when my Dialog's Edit Box Recieves "EN_KILLFOCUS".
It sets a corresponding TreeView Item's Text to the Edit Box's Text.

But for a reason I can't seem to pin down..
1
2
3
TreeView_EditLabel(hTree, htvItem)
// and..
(HWND)PostMessage(hDlg, TVM_EDITLABEL, 0, tvItem)
Are both returning NULL.

I've debugged the code block and my HTREEITEM initialises fine but, when I try to get the handle to the TreeView item edit box when TVM_EDITLABEL is sent. It returns NULL.

Here's my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
		case WM_COMMAND:
			switch (LOWORD(wParam)) // Control IDC_* or Menu IDM_*
			{
				case IDC_REG_NAMEEDIT: // Name Edit Box
				//=========================================================
					switch (HIWORD(wParam))
					{
						case EN_KILLFOCUS:
						{
							HTREEITEM hArchive;
							HWND      htvEdit;

							// Get Edit Control Text
							char buffer[MAX_PATH];
							GetWindowText(hNameEdit, buffer, MAX_PATH);

							// Get "Archive" ROOT_ITEM handle
							hArchive = TreeView_GetRoot(hTree);

							// Get the tv Edit Box
							htvEdit = TreeView_EditLabel(hTree, hArchive);

							// Set the text
							SetWindowText(htvEdit, buffer);

							// Stop Editing
							TreeView_EndEditLabelNow(hTree, false);

							// Nullify Pointers
							//---------------------------------------------------------
							hArchive = NULL;
							htvEdit  = NULL;
						}
						break;
					}
					
				break;

Here's a debug window snapshot:
http://i233.photobucket.com/albums/ee74/Lightfooted/Public/archiveDebugSnapshot1.png
Under htvEdit in the debug window it says "unable to read memory".

What do you suppose the issue is?
Last edited on
Topic archived. No new replies allowed.