예제 #1
0
 /// <summary>Initializes a new instance of the <see cref="TCITEM"/> class.</summary>
 public TCITEM(TabControlItemMask itemsToGet = TabControlItemMask.TCIF_ALL, TabControlItemStates statesToGet = TabControlItemStates.TCIS_ALL)
 {
     if ((itemsToGet & TabControlItemMask.TCIF_TEXT) != 0)
     {
         pszText = new StrPtrAuto(cchTextMax = 1024);
     }
 }
예제 #2
0
 public HDITEM(HeaderItemMask mask = HeaderItemMask.HDI_ALL)
 {
     if (mask.IsFlagSet(HeaderItemMask.HDI_TEXT))
     {
         pszText = new StrPtrAuto(cchTextMax = 1024);
     }
 }
예제 #3
0
        public void FreeTest()
        {
            var p1   = new StrPtrAuto(1024);
            var ptr1 = (IntPtr)p1;

            Assert.That(ptr1, Is.Not.EqualTo(IntPtr.Zero));
            p1.Free();
            ptr1 = (IntPtr)p1;
            Assert.That(ptr1, Is.EqualTo(IntPtr.Zero));
        }
예제 #4
0
        public void AssignConstantTest()
        {
            var p0 = new StrPtrAuto();

            Assert.That(p0.IsNull);
            p0.AssignConstant(1);
            Assert.That(!p0.IsNull);
            Assert.That((IntPtr)p0, Is.EqualTo(new IntPtr(1)));
            Assert.That(() => p0.Free(), Throws.Nothing);
        }
예제 #5
0
        public void StrPtrTest1()
        {
            var p1 = new StrPtrAuto(256);

            Assert.That(!p1.IsNull);
            Assert.That((string)p1, Is.EqualTo(""));
            var bytes = Marshal.SystemDefaultCharSize == 1 ? Encoding.ASCII.GetBytes("Test\0") : Encoding.Unicode.GetBytes("Test\0");

            Marshal.Copy(bytes, 0, (IntPtr)p1, bytes.Length);
            Assert.That((string)p1, Is.EqualTo("Test"));
            p1.Free();
        }
예제 #6
0
        public void StrPtrTest()
        {
            Assert.That(Marshal.SizeOf <StrPtrAuto>() == Marshal.SizeOf <IntPtr>());
            var p0 = new StrPtrAuto();

            Assert.That(p0.IsNull);
            var p1 = new StrPtrAuto("Test");

            Assert.That(!p1.IsNull);
            Assert.That((string)p1, Is.EqualTo("Test"));
            p1.Free();
        }
예제 #7
0
        public void AssignTest()
        {
            var p0 = new StrPtrAuto();

            Assert.That(p0.IsNull);
            p0.Assign("Test", out var cc);
            Assert.That(!p0.IsNull);
            Assert.That((string)p0, Is.EqualTo("Test"));
            Assert.That(cc, Is.EqualTo(5));
            p0.Free();
            var p1 = new StrPtrAuto("Test");

            Assert.That(!p1.IsNull);
            Assert.That((string)p1, Is.EqualTo("Test"));
            p1.Assign("Test2");
            Assert.That(!p1.IsNull);
            Assert.That((string)p1, Is.EqualTo("Test2"));
            p1.Free();
        }