博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
判断是否出现垂直滚动条
阅读量:4597 次
发布时间:2019-06-09

本文共 1642 字,大约阅读时间需要 5 分钟。

 

 

 

using System.Runtime.InteropServices;

 

private const int WS_HSCROLL = 0x100000;private const int WS_VSCROLL = 0x200000;private const int GWL_STYLE = (-16);  [DllImport("user32.dll")] private static extern int GetWindowLong(IntPtr hwnd, int nIndex);

 

///         /// 判断是否出现垂直滚动条        ///         /// 待测控件        /// 
出现垂直滚动条返回true,否则为false
public static bool IsVerticalScrollBarVisible(Control ctrl) { if (!ctrl.IsHandleCreated) return false; return (GetWindowLong(ctrl.Handle, GWL_STYLE) & WS_VSCROLL) != 0; }

 

 

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

 

 

 

ShowScrollBar Function

/*

* Scroll Bar Constants
*/
#define SB_HORZ             0
#define SB_VERT             1
#define SB_CTL              2
#define SB_BOTH             3

/*

隐藏和显示滚动条

[DllImport("user32.dll")]public static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow);

 

 

/** Scroll Bar Constants*/        public const int SB_HORZ = 0;        public const int SB_VERT = 1;        public const int SB_CTL = 2;        public const int SB_BOTH = 3;        /*        * ShowWindow() Commands        */        public const int SW_HIDE = 0;        public const int SW_SHOW = 5;
private void button1_Click(object sender, EventArgs e)        {            ShowScrollBar(listView1.Handle,SB_VERT , false);           }

 

 

 

 

 

转载于:https://www.cnblogs.com/xe2011/p/3439304.html

你可能感兴趣的文章
461. Hamming Distance
查看>>
Python垃圾回收机制详解
查看>>
{面试题1: 赋值运算符函数}
查看>>
Node中没搞明白require和import,你会被坑的很惨
查看>>
Python 标识符
查看>>
Python mysql 创建连接
查看>>
企业化的性能测试简述---如何设计性能测试方案
查看>>
centos7 安装中文编码
查看>>
POJ - 3683 Priest John's Busiest Day
查看>>
正则表达式start(),end(),group()方法
查看>>
vuejs 学习旅程一
查看>>
javascript Date
查看>>
linux常用命令2
查看>>
狼图腾
查看>>
13、对象与类
查看>>
Sublime Text3 个人使用心得
查看>>
jquery 编程的最佳实践
查看>>
MeetMe
查看>>
IP报文格式及各字段意义
查看>>
(转载)rabbitmq与springboot的安装与集成
查看>>