Thanks for any help or ideas on this. I'm trying to get the group collapse enabled on a ListView control for the Win Forms app. It works if a ListView control is placed on the form but if I derive a class from ListView or use a custom control then SendMessage fails with -1 result code.
Also note that the size (Marshal.Sizeof) of the LVGROUP is different when in the derived class. (40 vs 56). This is due to the LPTSTR or string members. Not sure if this is an issue, if I modify the form's struct to match the size it still works.
Thanks in advance,
Al
Here's some basic code:
int nRet;
LVGROUP group = new LVGROUP();
group.cbSize = Marshal.SizeOf(group);
group.state = (int)state; // LVGS_COLLAPSIBLE
group.mask = 4; // LVGF_STATE
group.iGroupId = (int)i;
nRet = SendMessage(aoc.Handle, 0x1000 + 147, i, ref group); // returns -1 if a derived class
[StructLayout(LayoutKind.Sequential)]
public struct LVGROUP
{
public int cbSize;
public int mask;
[MarshalAs(UnmanagedType.LPTStr)]
public string pszHeader;
public int cchHeader;
[MarshalAs(UnmanagedType.LPTStr)]
public string pszFooter;
public int cchFooter;
public int iGroupId;
public int stateMask;
public int state;
public int uAlign;
}