コード例 #1
0
 public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, ref HDITEM lParam);
コード例 #2
0
        private void SetColumnSortMark(SortOrder sortOrder, int columnIndex)
        {
            // Get HWND of Header control.
            IntPtr hHeader = User32.SendMessage(
                _lvwFiles.Handle, (UInt32)SysListView32.LVM_GETHEADER, 0, 0);

            // Initialize HDITEM. Retrieve `HDITEM.fmt' field only.
            HDITEM hdi = new HDITEM();
            hdi.mask = (uint)HDItemFlags.HDI_FORMAT;

            User32.SendMessage(hHeader, (UInt32)SysHeader32.HDM_GETITEMW,
                (UInt32)columnIndex, ref hdi);

            // Apply sorting arrow indicator flag to `HDITEM.fmt' field.
            hdi.mask = (uint)HDItemFlags.HDI_FORMAT;

            switch (sortOrder)
            {
                case SortOrder.Ascending:
                    hdi.fmt |= (int)HDItemFormat.HDF_SORTUP;
                    break;
                case SortOrder.Descending:
                    hdi.fmt |= (int)HDItemFormat.HDF_SORTDOWN;
                    break;
                case SortOrder.None:
                    hdi.fmt &= ~(int)(HDItemFormat.HDF_SORTUP | HDItemFormat.HDF_SORTDOWN);
                    break;
            }

            // Update column's format.
            User32.SendMessage(hHeader, (UInt32)SysHeader32.HDM_SETITEMW,
                (UInt32)columnIndex, ref hdi);
        }