Example #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));
            }
        }
Example #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();
        }
Example #3
0
 /// <summary>
 ///     Get an element of this list box by index.
 /// </summary>
 public string this[int index] {
     get {
         if (index < 0 || index >= Count)
         {
             throw new ArgumentException("Argument out of range");
         }
         int           length = SystemWindow.SendGetMessage(LB_GETTEXTLEN, (uint)index);
         StringBuilder sb     = new(length);
         SystemWindow.SendMessage(new HandleRef(this, SystemWindow.HWnd), LB_GETTEXT, new IntPtr(index), sb);
         return(sb.ToString());
     }
 }
        internal static SystemTreeViewItem[] FindSubItems(SystemWindow sw, IntPtr hParent)
        {
            List <SystemTreeViewItem> result = new List <SystemTreeViewItem>();
            IntPtr    hChild;
            HandleRef hr = new HandleRef(sw, sw.HWnd);

            if (hParent == IntPtr.Zero)
            {
                hChild = SystemWindow.SendMessage(hr, TVM_GETNEXTITEM, new IntPtr(TVGN_ROOT), IntPtr.Zero);
            }
            else
            {
                hChild = SystemWindow.SendMessage(hr, TVM_GETNEXTITEM, new IntPtr(TVGN_CHILD), hParent);
            }
            while (hChild != IntPtr.Zero)
            {
                result.Add(new SystemTreeViewItem(sw, hChild));
                hChild = SystemWindow.SendMessage(hr, TVM_GETNEXTITEM, new IntPtr(TVGN_NEXT), hChild);
            }
            return(result.ToArray());
        }
Example #5
0
 /// <summary>
 /// Ensures that a list-view item is either entirely or partially visible, scrolling the list-view control if necessary.
 /// </summary>
 /// <param name="rowIndex">Index of the row.</param>
 /// <param name="entirelyVisible">if set to <c>true</c> the item will be entirely visible.</param>
 public void EnsureItemIsVisible(int rowIndex, bool entirelyVisible)
 {
     SystemWindow.SendMessage(new HandleRef(sw, sw.HWnd), LVM_ENSUREVISIBLE, new IntPtr(rowIndex), new IntPtr(entirelyVisible ? 1 : 0));
 }