News:

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

help: TCM_GETITEM = 0

Started by Chambao, July 24, 2005, 08:51:15 AM

Previous topic - Next topic

Chambao

Hello

I have created 260 bytes using GlobalAlloc and GPTR flag, the return is successful.
I have stored the returned address in the lParam member of TCITEM successfully.
when my program terminates I try to free the allocated memory but lParam is 0 and SendMessage returns 0 as well on some of the items.
what could be the problem?

DestroyPages proc uses ebx esi
  xor ebx, ebx
  xcall SendMessage, hTabControl, TCM_GETITEMCOUNT, 0, 0
  mov esi, eax
  .repeat
    xcall DestroyPage, ebx
    inc ebx
  .until ebx == esi
  ret
DestroyPages endp


DestroyPage proc index:DWORD
  mov tab.imask, TCIF_PARAM
  xcall SendMessage, hTabControl, TCM_GETITEM, index, offset tab
  xcall GlobalFree, tab.lParam
  xcall SendMessage, hTabControl, TCM_DELETEITEM, index, 0
  ret
DestroyPage endp


this is my log file, and if you notice the addresses of tab 1 and 2 are incorrect but that is what SendMessage returned to me???

Quote@CreatePage(): 260 byte allocated, mem=1355184
@CreatePage(): TCM_INSERTITEM=0
@CreatePage(): tab.lParam=1355184

@CreatePage(): 260 byte allocated, mem=1381608
@CreatePage(): TCM_INSERTITEM=1
@CreatePage(): tab.lParam=1381608

@CreatePage(): 260 byte allocated, mem=1381928
@CreatePage(): TCM_INSERTITEM=2
@CreatePage(): tab.lParam=1381928

@CreatePage(): 260 byte allocated, mem=1376032
@CreatePage(): TCM_INSERTITEM=3
@CreatePage(): tab.lParam=1376032

@CreatePage(): 260 byte allocated, mem=1412488
@CreatePage(): TCM_INSERTITEM=4
@CreatePage(): tab.lParam=1412488

@DestroyPages(), TabCount = 5

@DestroyPage(), tab #0, TCM_GETITEM = 1
@DestroyPage(), tab #0, mem=1355184

@DestroyPage(), tab #1, TCM_GETITEM = 1
@DestroyPage(), tab #1, mem=1381928

@DestroyPage(), tab #2, TCM_GETITEM = 1
@DestroyPage(), tab #2, mem=1412488

@DestroyPage(), tab #3, TCM_GETITEM = 0
@DestroyPage(), tab #3, mem=0

@DestroyPage(), tab #4, TCM_GETITEM = 0
@DestroyPage(), tab #4, mem=0

thank you

Chambao

Hi

Someone already told me the error
I should pass 0 always to DeletePage()

DestroyPages proc uses ebx esi
  xor ebx, ebx
  xcall SendMessage, hTabControl, TCM_GETITEMCOUNT, 0, 0
  mov esi, eax
  .repeat
    xcall DestroyPage, [b]0[/b]
    inc ebx
  .until ebx == esi
  ret
DestroyPages endp