Пример #1
0
        public string GetItemText(int item, int subItem)
        {
            if (QueryItemText != null)
            {
                string lvtext;
                QueryItemText(item, subItem, out lvtext);
                if (lvtext != null)
                    return lvtext;
            }

            var _ms_lvi = new LVITEMW();
            _ms_lvi.mask = ListViewItemMask.LVIF_TEXT;
            _ms_lvi.iSubItem = subItem;
            _ms_lvi.cchTextMax = 512;
            _ms_lvi.pszText = Marshal.AllocCoTaskMem((_ms_lvi.cchTextMax)*2 /*Marshal.SizeOf(typeof(char))*/);
            try
            {
                SendMessage(Handle, ListViewMessages.LVM_GETITEMTEXT, item, ref _ms_lvi);
                return Marshal.PtrToStringAuto(_ms_lvi.pszText, _ms_lvi.cchTextMax);
            }
            finally
            {
                Marshal.FreeCoTaskMem(_ms_lvi.pszText);
            }
        }
Пример #2
0
 private static extern int SendMessage(IntPtr hWnd, ListViewMessages Msg, int wParam, ref LVITEMW lvitem);