当前位置: 首页>>代码示例>>C#>>正文


C# HDITEM类代码示例

本文整理汇总了C#中HDITEM的典型用法代码示例。如果您正苦于以下问题:C# HDITEM类的具体用法?C# HDITEM怎么用?C# HDITEM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HDITEM类属于命名空间,在下文中一共展示了HDITEM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetSortIcons

		public static void SetSortIcons(ListView listView, int previouslySortedColumn, int newSortColumn, SortOrder sorting) {
			IntPtr headerHandle = SendMessage(listView.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
			IntPtr newColumn = new IntPtr(newSortColumn);
			IntPtr prevColumn = new IntPtr(previouslySortedColumn);
			HDITEM hditem;
			// Only update the previous item if it existed and if it was a different one.
			if (previouslySortedColumn != -1 && previouslySortedColumn != newSortColumn) {
				// Clear icon from the previous column.
				hditem = new HDITEM();
				hditem.mask = HDI_FORMAT;
				ItemSendMessage(headerHandle, HDM_GETITEM, prevColumn, ref hditem);
				hditem.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
				ItemSendMessage(headerHandle, HDM_SETITEM, prevColumn, ref hditem);
			}
			// Set icon on the new column.
			hditem = new HDITEM();
			hditem.mask = HDI_FORMAT;
			ItemSendMessage(headerHandle, HDM_GETITEM, newColumn, ref hditem);
			if (sorting == SortOrder.Ascending) {
				hditem.fmt &= ~HDF_SORTDOWN;
				hditem.fmt |= HDF_SORTUP;
			}
			else {
				hditem.fmt &= ~HDF_SORTUP;
				hditem.fmt |= HDF_SORTDOWN;
			}
			ItemSendMessage(headerHandle, HDM_SETITEM, newColumn, ref hditem);
		}
开发者ID:TargetProcess,项目名称:Tp.Integration.Ide.VisualStudio,代码行数:28,代码来源:ListViewHelper.cs

示例2: SetSortIcon

        //extension method for setting "Sort Icon" of the listview.
        public static void SetSortIcon(this System.Windows.Forms.ListView ListViewControl, int ColumnIndex, System.Windows.Forms.SortOrder Order)
        {
            IntPtr ColumnHeader = SendMessage(ListViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            for (int ColumnNumber = 0; ColumnNumber <= ListViewControl.Columns.Count - 1; ColumnNumber++)
            {
                IntPtr ColumnPtr = new IntPtr(ColumnNumber);
                HDITEM item = new HDITEM();
                item.mask = (int)HDITEM.Mask.Format;
                SendMessageHDITEM(ColumnHeader, HDM_GETITEM, ColumnPtr, ref item);

                if (Order != System.Windows.Forms.SortOrder.None && ColumnNumber == ColumnIndex)
                {
                    switch (Order)
                    {
                        case System.Windows.Forms.SortOrder.Ascending:
                            item.fmt &= ~(int)HDITEM.Format.SortDown;
                            item.fmt |= (int)HDITEM.Format.SortUp;
                            break;
                        case System.Windows.Forms.SortOrder.Descending:
                            item.fmt &= ~(int)HDITEM.Format.SortUp;
                            item.fmt |= (int)HDITEM.Format.SortDown;
                            break;
                    }
                }
                else
                {
                    item.fmt &= ~(int)HDITEM.Format.SortDown & ~(int)HDITEM.Format.SortUp;
                }

                SendMessageHDITEM(ColumnHeader, HDM_SETITEM, ColumnPtr, ref item);
            }
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:34,代码来源:GenericListViewSorter.cs

示例3: SetSortIcon

        public static void SetSortIcon(this ListView listViewControl, int columnIndex, SortOrder order)
        {
            IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
            for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++)
            {
                var columnPtr = new IntPtr(columnNumber);
                var item = new HDITEM
                {
                    mask = HDITEM.Mask.Format
                };

                if (SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref item) == IntPtr.Zero)
                {
                    throw new Win32Exception();
                }

                if (order != SortOrder.None && columnNumber == columnIndex)
                {
                    switch (order)
                    {
                        case SortOrder.Ascending:
                            item.fmt &= ~HDITEM.Format.SortDown;
                            item.fmt |= HDITEM.Format.SortUp;
                            break;
                        case SortOrder.Descending:
                            item.fmt &= ~HDITEM.Format.SortUp;
                            item.fmt |= HDITEM.Format.SortDown;
                            break;
                    }
                }
                else
                {
                    item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp;
                }

                if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero)
                {
                    throw new Win32Exception();
                }
            }
        }
开发者ID:Zyx-A,项目名称:WakeOnLAN,代码行数:41,代码来源:listViewExtensions.cs

示例4: SetSortIcons

        public void SetSortIcons(int newSortColumn)
        {
            IntPtr hHeader = SendMessage(this.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
            IntPtr newColumn = new IntPtr(newSortColumn);
            IntPtr prevColumn = new IntPtr(_previouslySortedColumn);
            HDITEM hdItem;
            IntPtr rtn;

            // Only update the previous item if it existed and if it was a different one.
            if (_previouslySortedColumn != -1 && _previouslySortedColumn != newSortColumn)
            {
                // Clear icon from the previous column.
                hdItem = new HDITEM();
                hdItem.mask = HDI_FORMAT;
                rtn = SendMessageITEM(hHeader, HDM_GETITEM, prevColumn, ref hdItem);
                hdItem.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
                rtn = SendMessageITEM(hHeader, HDM_SETITEM, prevColumn, ref hdItem);
            }

            // Set icon on the new column.
            hdItem = new HDITEM();
            hdItem.mask = HDI_FORMAT;
            rtn = SendMessageITEM(hHeader, HDM_GETITEM, newColumn, ref hdItem);

            if (this.Sorting == SortOrder.Ascending)
            {
                hdItem.fmt &= ~HDF_SORTDOWN;
                hdItem.fmt |= HDF_SORTUP | HDF_BITMAP_ON_RIGHT;
            }
            else
            {
                hdItem.fmt &= ~HDF_SORTUP;
                hdItem.fmt |= HDF_SORTDOWN;
            }
            rtn = SendMessageITEM(hHeader, HDM_SETITEM, newColumn, ref hdItem);
            _previouslySortedColumn = newSortColumn;
        }
开发者ID:CaineQT,项目名称:hookme,代码行数:37,代码来源:ListViewEx.cs

示例5: SetColumnImage

        /// <summary>
        /// Setup the given column of the listview to show the given image to the right of the text.
        /// If the image index is -1, any previous image is cleared
        /// </summary>
        /// <param name="list">The listview to send a m to</param>
        /// <param name="columnIndex">Index of the column to modifiy</param>
        /// <param name="order"></param>
        /// <param name="imageIndex">Index into the small image list</param>
        public static void SetColumnImage(ListView list, int columnIndex, SortOrder order, int imageIndex)
        {
            IntPtr hdrCntl = NativeMethods.GetHeaderControl(list);
            if (hdrCntl.ToInt32() == 0)
                return;

            HDITEM item = new HDITEM();
            item.mask = HDI_FORMAT;
            IntPtr result = SendMessageHDItem(hdrCntl, HDM_GETITEM, columnIndex, ref item);

            item.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN | HDF_IMAGE | HDF_BITMAP_ON_RIGHT);

            if (NativeMethods.HasBuiltinSortIndicators()) {
                if (order == SortOrder.Ascending)
                    item.fmt |= HDF_SORTUP;
                if (order == SortOrder.Descending)
                    item.fmt |= HDF_SORTDOWN;
            }
            else {
                item.mask |= HDI_IMAGE;
                item.fmt |= (HDF_IMAGE | HDF_BITMAP_ON_RIGHT);
                item.iImage = imageIndex;
            }

            result = SendMessageHDItem(hdrCntl, HDM_SETITEM, columnIndex, ref item);
        }
开发者ID:seriesrenamer,项目名称:seriesrenamer,代码行数:34,代码来源:NativeMethods.cs

示例6: SendMessage

 public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam);
开发者ID:lscyane,项目名称:KCBr,代码行数:1,代码来源:ListViewExtensions.cs

示例7: hasSort

 private bool hasSort(int column)
 {
     if (Environment.OSVersion.Version.Major > 5)
     {
         HDITEM hi = new HDITEM();
         hi.mask = HDI_FORMAT;
         SendMessage(_hHeaderWnd, HDM_GETITEMA, column, ref hi);
         if ((hi.fmt & (HDF_SORTUP | HDF_SORTDOWN)) > 0)
             return true;
     }
     return false;
 }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:12,代码来源:cHeader.cs

示例8: hasButton

 private bool hasButton(int column)
 {
     if (Environment.OSVersion.Version.Major > 5)
     {
         HDITEM hi = new HDITEM();
         hi.mask = HDI_FORMAT;
         SendMessage(_hHeaderWnd, HDM_GETITEMA, columnAtIndex(column), ref hi);
         if ((hi.fmt & HDF_SPLITBUTTON) == HDF_SPLITBUTTON)
             return true;
     }
     return false;
 }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:12,代码来源:cHeader.cs

示例9: drawIcon

 private void drawIcon(IntPtr hdc, int column, RECT tr)
 {
     IntPtr iml = (IntPtr)SendMessage(_hHeaderWnd, HDM_GETIMAGELIST, HDIS_STATE, 0);
     if (iml != IntPtr.Zero)
     {
         int cx = 0;
         int cy = 0;
         HDITEM hi = new HDITEM();
         ImageList_GetIconSize(iml, out cx, out cy);
         hi.mask = HDI_IMAGE;
         SendMessage(_hHeaderWnd, HDM_GETITEMA, column, ref hi);
         tr.Top = (tr.Bottom - cy) / 2;
         tr.Left += 4;
         ImageList_DrawEx(iml, hi.iImage, hdc, tr.Left, tr.Top, cx, cy, CLR_NONE, 0, ILD_TRANSPARENT);
     }
 }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:16,代码来源:cHeader.cs

示例10: columnAtIndex

 private int columnAtIndex(int column)
 {
     HDITEM hd = new HDITEM();
     hd.mask = HDI_ORDER;
     for (int i = 0; i < ColumnCount; i++)
     {
         if (SendMessage(_hHeaderWnd, HDM_GETITEMA, column, ref hd) != IntPtr.Zero)
             return hd.iOrder;
     }
     return 0;
 }
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:11,代码来源:cHeader.cs

示例11: ItemSendMessage

		private static extern IntPtr ItemSendMessage(IntPtr Handle, Int32 msg, IntPtr wParam, ref HDITEM lParam);
开发者ID:TargetProcess,项目名称:Tp.Integration.Ide.VisualStudio,代码行数:1,代码来源:ListViewHelper.cs

示例12: SetHeaderImage

        /// <summary>
        /// Set the Header Column image
        /// </summary>
        /// <param name="list">ListView</param>
        /// <param name="columnIndex">Current column index</param>
        /// <param name="order">Current sort order</param>
        /// <param name="showImage">Display image in column (turn on/off image)</param>
        public static void SetHeaderImage(ListView list, int columnIndex, SortOrder order, bool showImage)
        {
            IntPtr _header;
             HDITEM _hdItem = new HDITEM();
             int _iconNumber = 0;

             //set the image index based on sort order from the smallimagelist property
             if( order == SortOrder.Ascending )
            _iconNumber = 0;
             else
            _iconNumber = 1;

             //get a handle to the listview header component
             _header = GetHeader(list.Handle);

             //set up the required structure members
             _hdItem.mask = HDI.IMAGE | HDI.FORMAT;
             _hdItem.pszText = list.Columns[columnIndex].Text;

             // check to show the indicator image
             if( showImage )
             {
            _hdItem.fmt = HDF.STRING | HDF.IMAGE | HDF.BITMAP_ON_RIGHT;
            _hdItem.iImage = _iconNumber;
             }
             else
            _hdItem.fmt = HDF.STRING;

             //modify the header
             SendMessage(_header, HDM.SETITEM, (uint)columnIndex, ref _hdItem);
        }
开发者ID:joshball,项目名称:astrogrep,代码行数:38,代码来源:Win32.cs

示例13: SetColumnPosition

 /// <summary>
 /// Set a column's position
 /// </summary>
 /// <param name="hwndLV">handle to listview</param>
 /// <param name="ColumnIndex">Column Index to set</param>
 /// <param name="iOrder">Position to set</param>
 public static void SetColumnPosition(IntPtr hwndLV, int ColumnIndex, int iOrder)
 {
     HDITEM hdi = new HDITEM();
      hdi.mask = HDI.ORDER;
      hdi.iOrder = iOrder;
      Header_SetItem(GetHeader(hwndLV), ColumnIndex, hdi);
 }
开发者ID:joshball,项目名称:astrogrep,代码行数:13,代码来源:Win32.cs

示例14: SendMessage

 /// <summary>
 /// 
 /// </summary>
 /// <param name="hWnd"></param>
 /// <param name="msg"></param>
 /// <param name="wParam"></param>
 /// <param name="lParam"></param>
 /// <returns></returns>
 public static int SendMessage(IntPtr hWnd, Enum msg, uint wParam, ref HDITEM lParam)
 {
     return SendMessage(hWnd, (uint)(WM)msg, wParam, ref lParam);
 }
开发者ID:joshball,项目名称:astrogrep,代码行数:12,代码来源:Win32.cs

示例15: Header_SetItem

 /// <summary>
 ///
 /// </summary>
 /// <param name="hwndHD"></param>
 /// <param name="index"></param>
 /// <param name="hdi"></param>
 /// <returns></returns>
 public static bool Header_SetItem(IntPtr hwndHD, int index, HDITEM hdi)
 {
     return SendMessage(hwndHD, HDM.SETITEM, (uint)index, ref hdi) != 0;
 }
开发者ID:joshball,项目名称:astrogrep,代码行数:11,代码来源:Win32.cs


注:本文中的HDITEM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。