コード例 #1
0
        // This overload method is used to set TreeView Item data.
        internal static unsafe bool SetItem(IntPtr hwnd, NativeMethods.TVITEM item)
        {
            ProcessorTypes localBitness;
            ProcessorTypes remoteBitness;
            GetProcessTypes(hwnd, out localBitness, out remoteBitness);

            if (localBitness == remoteBitness)
            {
                return XSend(hwnd, NativeMethods.TVM_SETITEMW, IntPtr.Zero, new IntPtr(&item), Marshal.SizeOf(item.GetType()));
            }
            else if (remoteBitness == ProcessorTypes.Processor32Bit)
            {
                TVITEM_32 item32 = new TVITEM_32(item);

                return XSend(hwnd, NativeMethods.TVM_SETITEMW, IntPtr.Zero, new IntPtr(&item32), Marshal.SizeOf(item32.GetType()));
            }
            else if (remoteBitness == ProcessorTypes.Processor64Bit)
            {
                TVITEM_64 item64 = new TVITEM_64(item);

                return XSend(hwnd, NativeMethods.TVM_SETITEMW, IntPtr.Zero, new IntPtr(&item64), Marshal.SizeOf(item64.GetType()));
            }
            return false;
        }
コード例 #2
0
        // This overload method is used to get TreeView Item Text.
        internal static unsafe string GetItemText(IntPtr hwnd, NativeMethods.TVITEM item)
        {
            ProcessorTypes localBitness;
            ProcessorTypes remoteBitness;
            GetProcessTypes(hwnd, out localBitness, out remoteBitness);

            if (localBitness == remoteBitness)
            {
                return GetTextWithinStructure(hwnd, NativeMethods.TVM_GETITEMW, IntPtr.Zero, new IntPtr(&item), Marshal.SizeOf(item.GetType()), new IntPtr(&item.pszText), item.cchTextMax);
            }
            else if (remoteBitness == ProcessorTypes.Processor32Bit)
            {
                TVITEM_32 item32 = new TVITEM_32(item);

                return GetTextWithinStructureRemoteBitness(
                            hwnd, NativeMethods.TVM_GETITEMW, IntPtr.Zero, new IntPtr(&item32),
                            Marshal.SizeOf(item32.GetType()), new IntPtr(&item32.pszText), item32.cchTextMax,
                            remoteBitness, false);
            }
            else if (remoteBitness == ProcessorTypes.Processor64Bit)
            {
                TVITEM_64 item64 = new TVITEM_64(item);

                return GetTextWithinStructure(hwnd, NativeMethods.TVM_GETITEMW, IntPtr.Zero, new IntPtr(&item64), Marshal.SizeOf(item64.GetType()), new IntPtr(&item64.pszText), item64.cchTextMax);
            }
            return "";
        }