News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Retrieving listview group text.

Started by georgek01, July 31, 2006, 06:42:09 AM

Previous topic - Next topic

georgek01

Hello!!

I'm having some trouble retrieving the group header text of a listview item.

I have confirmed that the group ID I'm passing in exists and the call for LVM_GETGROUPINFO returns successful - but the buffer [ListBuffer] is empty.  :(



.data?

ListBuffer db 256 dup(?)
wListBuffer db 512 dup(?)

.code

...

mov iGroup,eax ; set the required group ID

invoke GetGroupText, hList, iGroup

GetGroupText proc h:DWORD, iIndex:DWORD

Invoke RtlZeroMemory,ADDR _lvg,sizeof LVGROUP
invoke RtlZeroMemory,addr wListBuffer,sizeof wListBuffer ; buffer receiving wide chars
invoke RtlZeroMemory,addr ListBuffer,sizeof ListBuffer ; conversion buffer from wide to multibyte chars

mov _lvg.cbSize, sizeof _lvg
mov _lvg.imask, LVGF_HEADER
mov _lvg.pszHeader, offset wListBuffer
mov _lvg.cchHeader, sizeof wListBuffer

invoke SendMessage,h,LVM_GETGROUPINFO,iIndex,addr _lvg
.if eax != -1
invoke WideCharToMultiByte,CP_ACP,0,addr wListBuffer,512,addr ListBuffer,sizeof ListBuffer,NULL,NULL
invoke lstrlen,addr ListBuffer ; if buffer is empty, return error
.if eax != 0
lea eax,offset ListBuffer
.else
mov eax,-1
.endif
.else
mov eax,-1
.endif

Ret
GetGroupText EndP



May it be my call to WideCharToMultiByte that's incorrect? I've tested for the length of buffer [wListBuffer] too, and that also appears to be zero.

Any assistance will be greatly appreciated!!
What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)

morlok

One Visible..

          lea eax,offset ListBuffer


must be


         lea eax, ListBuffer

georgek01

Thanks for the response morlok! Unfortunately the buffer is still empty. I tested using a message box...


lea eax,ListBuffer
invoke MessageBox,NULL,eax,NULL,MB_OK
What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)

morlok

#3
Try This (wiht _lvg.pszHeader instead of the buffer)

         invoke WideCharToMultiByte,CP_ACP,0, _lvg.pszHeader, -1, addr ListBuffer,sizeof ListBuffer,NULL,NULL
         invoke lstrlen,addr ListBuffer ; if buffer is empty, return error
.if eax != 0
lea eax, ListBuffer
.else
mov eax,-1
.endif


georgek01

thanks morlok  :U that works nicely!!!
What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)