示例#1
0
        /// <summary>
        ///     A subitem (a column value) of an item of this list view.
        /// </summary>
        public SystemListViewItem this[int index, int subIndex] {
            get {
                LVITEM lvi = new();
                lvi.cchTextMax = 300;
                lvi.iItem      = index;
                lvi.iSubItem   = subIndex;
                lvi.stateMask  = 0xffffffff;
                lvi.mask       = LVIF_IMAGE | LVIF_STATE | LVIF_TEXT;
                ProcessMemoryChunk tc = ProcessMemoryChunk.Alloc(sw.Process, 301);
                lvi.pszText = tc.Location;
                ProcessMemoryChunk lc = ProcessMemoryChunk.AllocStruct(sw.Process, lvi);
                ApiHelper.FailIfZero(SystemWindow.SendMessage(new HandleRef(sw, sw.HWnd), LVM_GETITEM, IntPtr.Zero,
                                                              lc.Location));
                lvi = (LVITEM)lc.ReadToStructure(0, typeof(LVITEM));
                lc.Dispose();
                if (lvi.pszText != tc.Location)
                {
                    tc.Dispose();
                    tc = new ProcessMemoryChunk(sw.Process, lvi.pszText, lvi.cchTextMax);
                }

                byte[] tmp   = tc.Read();
                string title = Encoding.Default.GetString(tmp);
                if (title.IndexOf('\0') != -1)
                {
                    title = title.Substring(0, title.IndexOf('\0'));
                }
                int  image = lvi.iImage;
                uint state = lvi.state;
                tc.Dispose();
                return(new SystemListViewItem(sw, index, title, state, image));
            }
        }
示例#2
0
        /// <summary>
        /// Sets the selected-state of the item.
        /// </summary>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="selected">if set to <c>true</c> the item will be selected.</param>
        public void SetItemSelectedState(int rowIndex, bool selected)
        {
            LVITEM lvi = new LVITEM();

            lvi.stateMask = (uint)(ListViewItemState.LVIS_SELECTED);
            lvi.state     = selected ? (uint)(ListViewItemState.LVIS_SELECTED) : 0;
            ProcessMemoryChunk lc = ProcessMemoryChunk.AllocStruct(sw.Process, lvi);

            SystemWindow.SendMessage(new HandleRef(sw, sw.HWnd), LVM_SETITEMSTATE, new IntPtr(rowIndex), lc.Location);
            lc.Dispose();
        }