Example #1
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_CONTEXTMENU)
            {
                if (!_OnItemsArea && this.Handle != m.WParam)
                {
                    // 水平方向
                    API.ScrollInfoStruct si = new API.ScrollInfoStruct();

                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = API.SIF_RANGE | API.SIF_POS | API.SIF_PAGE;
                    API.GetScrollInfo(this.Handle, API.SB_HORZ, ref si);

                    Point p          = base.PointToClient(MousePosition);
                    int   totalWidth = 0;

                    int nColumnHeaderHeight = ListViewUtil.GetColumnHeaderHeight(this);
                    if (p.Y >= 0 && p.Y < nColumnHeaderHeight)
                    {
                        foreach (ColumnHeader column in base.Columns)
                        {
                            totalWidth += column.Width;
                            if (p.X + si.nPos < totalWidth)
                            {
                                if (ColumnContextMenuClicked != null)
                                {
                                    ColumnContextMenuClicked(this, column);
                                    return;
                                }
                                break;
                            }
                        }
                    }
                }
            }

            base.WndProc(ref m);
        }
Example #2
0
        void SetScrollBars(ScrollBarMember member)
        {
            nNestedSetScrollBars++;


            try
            {
                int nClientWidth  = this.ClientSize.Width;
                int nClientHeight = this.ClientSize.Height;

                // 文档尺寸
                long lDocumentWidth  = DocumentWidth;
                long lDocumentHeight = DocumentHeight;

                long lWindowOrgX = this.m_lWindowOrgX;
                long lWindowOrgY = this.m_lWindowOrgY;

                if (member == ScrollBarMember.Horz ||
                    member == ScrollBarMember.Both)
                {
                    if (TooLarge(lDocumentWidth) == true)
                    {
                        this.m_h_ratio = (double)(Int16.MaxValue - 1) / (double)lDocumentWidth;

                        lDocumentWidth = (long)((double)lDocumentWidth * m_h_ratio);
                        nClientWidth   = (int)((double)nClientWidth * m_h_ratio);
                        lWindowOrgX    = (long)((double)lWindowOrgX * m_h_ratio);
                    }
                    else
                    {
                        this.m_h_ratio = 1.0F;
                    }

                    // 水平方向
                    API.ScrollInfoStruct si = new API.ScrollInfoStruct();

                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = API.SIF_RANGE | API.SIF_POS | API.SIF_PAGE;
                    si.nMin   = 0;
                    si.nMax   = (int)lDocumentWidth;
                    si.nPage  = nClientWidth;
                    si.nPos   = -(int)lWindowOrgX;
                    API.SetScrollInfo(this.Handle, API.SB_HORZ, ref si, true);
                }


                if (member == ScrollBarMember.Vert ||
                    member == ScrollBarMember.Both)
                {
                    if (TooLarge(lDocumentHeight) == true)
                    {
                        this.m_v_ratio = (double)(Int16.MaxValue - 1) / (double)lDocumentHeight;

                        lDocumentHeight = (long)((double)lDocumentHeight * m_v_ratio);
                        nClientHeight   = (int)((double)nClientHeight * m_v_ratio);
                        lWindowOrgY     = (long)((double)lWindowOrgY * m_v_ratio);
                    }
                    else
                    {
                        this.m_v_ratio = 1.0F;
                    }

                    // 垂直方向
                    API.ScrollInfoStruct si = new API.ScrollInfoStruct();

                    si.cbSize = Marshal.SizeOf(si);
                    si.fMask  = API.SIF_RANGE | API.SIF_POS | API.SIF_PAGE;
                    si.nMin   = 0;
                    si.nMax   = (int)lDocumentHeight;
                    si.nPage  = nClientHeight;
                    si.nPos   = -(int)lWindowOrgY;
                    // Debug.Assert(si.nPos != 0, "");
                    API.SetScrollInfo(this.Handle, API.SB_VERT, ref si, true);
                }
            }
            finally
            {
                nNestedSetScrollBars--;
            }
        }
Example #3
0
		// 设卷滚条
		void SetScrollBars(ScrollBarMember member)
		{
			if (bAutoSize == true) 
			{
				API.ShowScrollBar(this.Handle,
					API.SB_HORZ,
					false);
				API.ShowScrollBar(this.Handle,
					API.SB_VERT,
					false);
				return;
			}

			nClientWidth = this.ClientSize.Width;
			nClientHeight = this.ClientSize.Height;

			if (member == ScrollBarMember.Horz
				|| member == ScrollBarMember.Both) 
			{
				// 水平方向
				API.ScrollInfoStruct si = new API.ScrollInfoStruct();
				si.cbSize = Marshal.SizeOf(si);
				si.fMask = API.SIF_RANGE | API.SIF_POS | API.SIF_PAGE;
				si.nMin = 0;
				si.nMax = DocumentWidth ;
				si.nPage = nClientWidth;
				si.nPos = -nDocumentOrgX;
				API.SetScrollInfo(this.Handle, API.SB_HORZ, ref si, true);
			}


			if (member == ScrollBarMember.Vert
				|| member == ScrollBarMember.Both) 
			{
				// 垂直方向
				API.ScrollInfoStruct si = new API.ScrollInfoStruct();
				si.cbSize = Marshal.SizeOf(si);
				si.fMask = API.SIF_RANGE | API.SIF_POS | API.SIF_PAGE;
				si.nMin = 0;
				si.nMax = DocumentHeight ;
				si.nPage = nClientHeight;
				si.nPos = -nDocumentOrgY;
				API.SetScrollInfo(this.Handle, API.SB_VERT, ref si, true);
			}
		}