Exemple #1
0
        /// <summary> Overridden window message processing. </summary>
        protected override void WndProc(ref Message Msg)
        {
            if (Msg.Msg == ListViewWin32.WM_MOUSEMOVE)
            {
                int PosX = ListViewWin32.GET_X_LPARAM(( uint )Msg.LParam);
                int PosY = ListViewWin32.GET_Y_LPARAM(( uint )Msg.LParam);

                int ColumnStart = 0;
                int ColumnEnd   = 0;
                CurrentColumnIndex = -1;

                // Find on which column we should show the tooltip.
                for (int ColumnIndex = 0; ColumnIndex < Parent.Columns.Count; ColumnIndex++)
                {
                    int ColumnWidth = Parent.Columns[ColumnIndex].Width;
                    ColumnEnd = ColumnStart + ColumnWidth;

                    if (PosX >= ColumnStart && PosX < ColumnEnd)
                    {
                        CurrentColumnIndex = ColumnIndex;
                        break;
                    }

                    ColumnStart = ColumnEnd;
                }

                if (CurrentColumnIndex == -1)
                {
                    HeaderToolTip.Hide(Parent);
                }
                else if (CurrentColumnIndex != LastColumnIndex)
                {
                    ListViewWin32.TRACKMOUSEEVENT trackMouseEvent = new ListViewWin32.TRACKMOUSEEVENT(ListViewWin32.ETrackMouseEvent.TME_HOVER, Handle, ListViewWin32.HOVER_DEFAULT);
                    ListViewWin32.TrackMouseEvent(ref trackMouseEvent);

                    HeaderToolTip.Hide(Parent);
                }

                LastColumnIndex = CurrentColumnIndex;
            }
            else if (Msg.Msg == ListViewWin32.WM_MOUSELEAVE)
            {
                HeaderToolTip.Hide(Parent);
                LastColumnIndex = -1;
            }
            else if (Msg.Msg == ListViewWin32.WM_MOUSEHOVER)
            {
                if (bAllowTooltips && CurrentColumnIndex != -1)
                {
                    int PosX = ListViewWin32.GET_X_LPARAM(( uint )Msg.LParam);
                    int PosY = ListViewWin32.GET_Y_LPARAM(( uint )Msg.LParam);

                    // Show tooltip.
                    HeaderToolTip.Show(Parent.ColumnsTooltips[CurrentColumnIndex], Parent, PosX, PosY + 32);
                }
            }
            // Default processing.
            base.WndProc(ref Msg);
        }
Exemple #2
0
        /// <summary> Default constructor. </summary>
        public FListViewHeader(ListViewEx InParent)
        {
            Parent = InParent;
            // Get the header control window.
            IntPtr HeaderWindow = ListViewWin32.SendMessage(Parent.Handle, ListViewWin32.LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            AssignHandle(HeaderWindow);

            // Only allow tooltips if data is valid.
            bAllowTooltips = Parent.ColumnsTooltips.Count == Parent.Columns.Count;

            // Assign tooltip to the parent control.
            HeaderToolTip.SetToolTip(Parent, "ListViewEx");
        }
Exemple #3
0
        /// <summary> Sets the sort arrow to a particular column in the list view. </summary>
        /// <param name="ColumnToShowArrow"> Index of the column where the sort arrow will be displayed </param>
        public void SetSortArrow(int ColumnToShowArrow, bool bSortModeAscending)
        {
            if (ListViewHeader == null)
            {
                return;
            }

            IntPtr ColumnHeader = ListViewHeader.Handle;

            for (int ColumnIndex = 0; ColumnIndex < Columns.Count; ColumnIndex++)
            {
                IntPtr ColumnPtr = new IntPtr(ColumnIndex);
                ListViewWin32.HDITEM ListViewColumn = new ListViewWin32.HDITEM();
                ListViewColumn.mask = ListViewWin32.HDI_FORMAT;
                ListViewWin32.SendMessageHeaderItem(ColumnHeader, ListViewWin32.HDM_GETITEM, ColumnPtr, ref ListViewColumn);

                bool bIsSortArrowDown = ((ListViewColumn.fmt & ListViewWin32.HDF_SORTDOWN) == ListViewWin32.HDF_SORTDOWN);
                bool bIsSortArrowUp   = ((ListViewColumn.fmt & ListViewWin32.HDF_SORTUP) == ListViewWin32.HDF_SORTUP);

                // Change the sort arrow to opposite direction.
                if (ColumnToShowArrow == ColumnIndex)
                {
                    if (bSortModeAscending)
                    {
                        ListViewColumn.fmt &= ~ListViewWin32.HDF_SORTDOWN;
                        ListViewColumn.fmt |= ListViewWin32.HDF_SORTUP;
                    }
                    else
                    {
                        ListViewColumn.fmt &= ~ListViewWin32.HDF_SORTUP;
                        ListViewColumn.fmt |= ListViewWin32.HDF_SORTDOWN;
                    }
                }
                else
                {
                    ListViewColumn.fmt &= ~ListViewWin32.HDF_SORTDOWN & ~ListViewWin32.HDF_SORTUP;
                }

                ListViewWin32.SendMessageHeaderItem(ColumnHeader, ListViewWin32.HDM_SETITEM, ColumnPtr, ref ListViewColumn);
            }
        }