I get the handle of a header control with LVM_GETHEADER
The listview has 12 columns.
If I use HDM_ITEMCOUNT it returns 12.

Then I call HDM_GETIETM with hdi.mask = HDI_FORMAT.
If I call HDM_SETITEM on the same column, without chaging anything, the program crashes with exception 0xc000005.
The memory at address 00000000 cannot be read.

Why???????
Posted on 2004-02-24 16:20:22 by greenant
Hi Greenant,

You will have to post the code, it should not do that. Remember that the item in HDM_SETITEM is zero based so you will have to subtract 1 (0...11 for 12 columns). It sounds to me like you are also specifying HDI_TEXT, and not filling the pszText field.
Posted on 2004-02-24 16:41:33 by donkey
I'm writing a program that is mixed c++/asm.
The main exe (written in c++) uses plugins (written in c++ or asm).
Now I have problem with a c++ plugin, not an asm one.

This is the code


HDITEM hdi;
HWND hHeader = ListView_GetHeader(hList);

//Remove the bitmap in the previous sorted column
hdi.mask = HDI_FORMAT;
Header_GetItem(hHeader, SortCol, &hdi);

hdi.fmt &= (~HDF_BITMAP);
Header_SetItem(hHeader, SortCol, &hdi);

SortCol can be any number. It crashes anyway
This piece of code is translated from an assembler program I did a year ago.
In assembler it works.

The aim of this code is to place a correct icon (up arrow or down arrow) in the sorted column of a listview.
First I have remove the bitmap from the previous sorted column.

The exception arises when I call Header_SetItem(....);

I tried to debug it with visual studio 6.0 but it crashes only when I compile the dll as release. If I use debug all is ok.
I tried to use ollydbg to debug the dll without symbols.

It crashes in this piece of code


nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
mov eax, [ecx]
retn
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop


It crashes because ecx is zero.
The memory address of mov eax, is 10005580
while the address of Header_SetItem is 10005752

I cannot understand why it crashes. And I why it crashes in my module and not in windows????
I tried to disassemble it with w32dasm but it doesn't open the dll. It gives no error message. I select the dll, click open, and w32dasm closes the GetOpenFileName dialog box and return to the main window as if I clicked cancel

Do you know a good disassembler that I can use instead of w32dasm?
Posted on 2004-02-25 03:47:29 by greenant
Problem solved.
It was a problem of Common Controls 6 and WM_NOTIFY
Posted on 2004-02-25 03:54:50 by greenant
Had the same problem with my toolbar menu demo, had to do a phantom WM_NOTIFY that was a WM_USER and jumped directly into WM_NOTIFY. You will also find a few funny things with WM_NOTIFY on ME.
Posted on 2004-02-25 04:01:55 by donkey