Пример #1
0
		// 设卷滚条
		// parameter:
		//		member	
		private void SetScrollBars(ScrollBarMember member)
		{
			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 = this.DocumentWidth;
				si.nPage = this.ClientWidth;
				si.nPos = - this.DocumentOrgX;
				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 = this.DocumentHeight;
				si.nPage = this.ClientHeight;
				si.nPos = -this.DocumentOrgY;
				API.SetScrollInfo(this.Handle, API.SB_VERT, ref si, true);
			}
		}
Пример #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--;
            }
        }