zoukankan      html  css  js  c++  java
  • 判断控件是否出现了滚动条

    收藏自:https://blog.csdn.net/ltolll/article/details/7637995

    经测试,有效。

      private const int WS_HSCROLL = 0x100000;
            private const int WS_VSCROLL = 0x200000;
            private const int GWL_STYLE = (-16);

            [System.Runtime.InteropServices.DllImport("user32", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
            private static extern int GetWindowLong(IntPtr hwnd, int nIndex);

            /// <summary>
            /// 判断是否出现垂直滚动条
            /// </summary>
            /// <param name="ctrl">待测控件</param>
            /// <returns>出现垂直滚动条返回true,否则为false</returns>
            internal static bool IsVerticalScrollBarVisible(Control ctrl)
            {
                if (!ctrl.IsHandleCreated)
                    return false;

                return (GetWindowLong(ctrl.Handle, GWL_STYLE) & WS_VSCROLL) != 0;
            }

            /// <summary>
            /// 判断是否出现水平滚动条
            /// </summary>
            /// <param name="ctrl">待测控件</param>
            /// <returns>出现水平滚动条返回true,否则为false</returns>
            internal static bool IsHorizontalScrollBarVisible(Control ctrl)
            {
                if (!ctrl.IsHandleCreated)
                    return false;
                return (GetWindowLong(ctrl.Handle, GWL_STYLE) & WS_HSCROLL) != 0;
            }

  • 相关阅读:
    小儿吃鸡蛋食积案
    女子经前胀痛脸上红斑案
    小儿外感咳嗽咽痛案
    顽固偏头痛案
    交通心肾治失眠
    小儿扁桃体高热兼咳嗽案
    过敏疾患与太少两感相合
    经前乳胀案
    女子黃带案
    小儿外感后频繁眨眼案
  • 原文地址:https://www.cnblogs.com/81/p/9579431.html
Copyright © 2011-2022 走看看