Hi all friends,

I'm create a treeview and nm_treeview struct for notify. I want to move selected item text to my buffer. But my psztext adress not adressing any text data.(I don't get text data) My proc is below:



tvnotify:
.if wParam == 3008 ; Treeview
mov eax,lParam
mov ebx,(nm_treeview ptr [eax]).hdr_code
.if ebx == TVN_SELCHANGED
mov ebx,lParam
mov [ebx].nm_treeview.tnew_imask,TVIF_TEXT or TVIF_HANDLE
mov [ebx].nm_treeview.tnew_psztext, offset itembuf
mov dword ptr [ebx].nm_treeview.tnew_cchtextmax,128
call SendMessageA,tvhw,TVM_GETITEM,0, nm_treeview.tnew
call MessageBoxA,0,offset itembuf ,offset capt,MB_OK
.endif
.endif
ret





What is my wrong ?

Thanks,

[ Excuse me my bad English... ]

Regards,
Posted on 2003-08-07 10:38:51 by CYDONIA
From MSDN:

If the TVIF_TEXT flag is set in the mask member of the TVITEM or TVITEMEX structure, the pszText member must point to a valid buffer and the cchTextMask member must be set to the number of characters in that buffer. The returned text will not necessarily be stored in the original buffer passed by the application. It is possible that pszText will point to text in a new buffer rather than place it in the old buffer.

Perhaps this will help. :alright:
Posted on 2003-08-07 12:55:57 by QvasiModo
Possibly this line is a problem:



call SendMessageA,tvhw,TVM_GETITEM,0, nm_treeview.tnew


if nm_treeview.tnew is a structure/variable inside nm_treeview, you are pushing the offset of this
structure, which is surely wrong.

Japheth
Posted on 2003-08-07 13:35:25 by japheth
Indeed, you should push the address of a TV_ITEM structure, not the structure data itself.
Posted on 2003-08-07 13:46:43 by QvasiModo
Thanks for all reply's,

I need more work under this code. I'm sure my code not valid.

Regards,
Posted on 2003-08-07 14:42:09 by CYDONIA
This should work... try it



tvnotify:
.if wParam == 3008 ; Treeview
mov eax,lParam
mov ebx,(nm_treeview ptr [eax]).hdr_code
.if ebx == TVN_SELCHANGED
mov ebx,lParam
mov [ebx].nm_treeview.tnew_imask,TVIF_TEXT or TVIF_HANDLE
mov [ebx].nm_treeview.tnew_psztext, offset itembuf
mov dword ptr [ebx].nm_treeview.tnew_cchtextmax,128
call SendMessageA,tvhw,TVM_GETITEM,0, addr [ebx].nm_treeview.tnew
call MessageBoxA,0,addr [ebx].nm_treeview.tnew_psztext ,offset capt,MB_OK
.endif
.endif
ret

Posted on 2003-08-07 14:55:16 by QvasiModo
Thanks QvasiModo, I'm trying but not working. I'm cutting unnecessary sections and I attach just treeview section.

I'm sure my code wrong, but i don't found where error.

Regards,
Posted on 2003-08-08 08:32:51 by CYDONIA
I tried opening your program with a debugger, and it seems that the notification message never arrives. So the problem does not seem to be in the code you posted, but somewhere else... Try figuring out why the message is not being received, that could be the key to this problem.

EDIT: I was talking nonsense. Now I see the problem is the treeview never gets to be displayed because it fails on CreateFile call on startup... I'll create this my.txt file and try again.
Posted on 2003-08-08 10:42:43 by QvasiModo
Access violation when expanding the treeview node. It's in the code you posted, alright...
Try using this structure instead, maybe that's the problem...


NMHDR STRUCT
hwndFrom DWORD ?
idFrom DWORD ?
code DWORD ?
NMHDR ends

TVITEMA STRUCT
_mask DWORD ?
hItem DWORD ?
state DWORD ?
stateMask DWORD ?
pszText DWORD ?
cchTextMax DWORD ?
iImage DWORD ?
iSelectedImage DWORD ?
cChildren DWORD ?
lParam DWORD ?
TVITEMA ENDS

TVITEM equ <TVITEMA>

NM_TREEVIEW STRUCT
hdr NMHDR <>
action DWORD ?
itemOld TVITEM <>
itemNew TVITEM <>
ptDrag POINT <>
NM_TREEVIEW ENDS

Also you need to preserve EBX, or it will crash in some Windows versions.
Posted on 2003-08-08 10:52:00 by QvasiModo
Hi CYDONIA,

Quasimodo advised you to change your code to



call SendMessageA,tvhw,TVM_GETITEM,0, addr [ebx].nm_treeview.tnew


and you "translated" that to



call SendMessageA,tvhw,TVM_GETITEM,0, offset [ebx].nm_treeview.tnew_imask


which is wrong IMHO. ADDR and OFFSET arent identical operators! If you dont want to use ADDR, use


LEA ecx, [ebx].nm_treeview.tnew_imask
call SendMessageA,tvhw,TVM_GETITEM,0, ecx


Japheth
Posted on 2003-08-08 17:59:42 by japheth