Ejemplo n.º 1
0
 public static extern int SetSelected
 (
     IntPtr hWnd,
     int Msg,
     int wParam,
     ref LVITEMW lvitem
 );
Ejemplo n.º 2
0
        public unsafe void UpdateText_should_throw_AOOR_if_cchTextMax_less_than_1()
        {
            var lvi = new LVITEMW
            {
                cchTextMax = 0,
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => lvi.UpdateText("012345"));
        }
 private int DisplayIndexToID(int displayIndex)
 {
     Debug.Assert(!owner.VirtualMode, "in virtual mode, this method does not make any sense");
     if (owner.IsHandleCreated && !owner.ListViewHandleDestroyed)
     {
         // Obtain internal index of the item
         var lvItem = new LVITEMW
         {
             mask  = LVIF.PARAM,
             iItem = displayIndex
         };
         User32.SendMessageW(owner, (User32.WM)LVM.GETITEMW, IntPtr.Zero, ref lvItem);
         return((int)lvItem.lParam);
     }
     else
     {
         return(this[displayIndex].ID);
     }
 }
Ejemplo n.º 4
0
        public unsafe void UpdateText_should_set_null_terminated_text()
        {
            string originalText = "abcdefghi";

            fixed(char *pOriginalText = originalText)
            {
                var lvi = new LVITEMW
                {
                    cchTextMax = originalText.Length,
                    pszText    = pOriginalText
                };

                lvi.UpdateText("012345");

                var sText = new ReadOnlySpan <char>(lvi.pszText, lvi.cchTextMax);

                Assert.Equal(sText.ToArray(), new char[] { '0', '1', '2', '3', '4', '5', '\0' });
            }
        }
Ejemplo n.º 5
0
        public unsafe void UpdateText_should_limit_input_text_to_cchTextMax_less_1_text_longer(string originalText, int maxLength, string newText, string expected)
        {
            fixed(char *pOriginalText = originalText)
            {
                var lvi = new LVITEMW
                {
                    cchTextMax = maxLength,
                    pszText    = pOriginalText
                };

                lvi.UpdateText(newText);

                var text = new string(lvi.pszText);

                Assert.Equal(expected, text);
                Assert.Equal(maxLength - 1, text.Length);
                Assert.Equal(text.Length + 1, lvi.cchTextMax);
                Assert.Equal(maxLength, lvi.cchTextMax);
            }
        }
Ejemplo n.º 6
0
        public unsafe void UpdateText_should_set_cchTextMax_to_input_text_length_plus_1_if_text_shorter()
        {
            string originalText = "abcdefghi";

            fixed(char *pOriginalText = originalText)
            {
                var lvi = new LVITEMW
                {
                    cchTextMax = originalText.Length,
                    pszText    = pOriginalText
                };

                lvi.UpdateText("012345");

                var sText = new ReadOnlySpan <char>(lvi.pszText, lvi.cchTextMax);

                var text = new string(lvi.pszText);

                Assert.Equal("012345", text);
                Assert.Equal(lvi.cchTextMax, text.Length + 1);
            }
        }
Ejemplo n.º 7
0
 public static extern IntPtr SendMessage_LvItem(IntPtr hWnd, int Msg, IntPtr nIndex, ref LVITEMW pItem);