[英]Is it possible to query the WebBrowser control whether the horizontal scrollbar is visible?
Using a WebBrowser
control in my Windows Forms application, I want to retrieve the information, whether a horizontal scrollbar is currently being shown. 在我的Windows窗体应用程序中使用
WebBrowser
控件 ,我想检索信息,当前是否显示水平滚动条。
Eg I want to create a function/property, let's call it " HasHorzontalScrollbar
", that either returns true
or false
: 例如,我想创建一个函数/属性,让我们称之为“
HasHorzontalScrollbar
”,它返回true
或false
:
I've tried to use Spy++ to inspect the window and I tried to read the size from the window similar the following, but I'm still unable to get meaningful values: 我曾尝试使用Spy ++检查窗口,我试图从窗口中读取大小类似于以下内容,但我仍然无法获得有意义的值:
var height1 = webBrowser1.Document.Window.Size.Height;
var height2 = webBrowser1.Height;
My question is: 我的问题是:
Is there a way to query the WebBrowser
whether the horizontal scrollbar is currently visible? 有没有办法查询
WebBrowser
水平滚动条当前是否可见?
Edit: Solved 编辑:解决了
Thanks to the help from Yahia , I was able to develop a solution: 感谢Yahia的帮助,我能够开发出一个解决方案:
public bool HasHorizontalScrollbar
{
get
{
var width1 = webBrowser.Document.Body.ScrollRectangle.Width;
var width2 = webBrowser.Document.Window.Size.Width;
return width1 > width2;
}
}
This works in my test environment. 这适用于我的测试环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.