[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

Removing scroll bars from WEB Browser

Is there anyway to remove/restore the scroll bars from the WEB browser control?

First off, nothing short of subclassing seems to get the actual handle to control window (Web.hwnd doesn't work) & even trapping the class name & then using a SendMessage API call to remove the scrollbars deosn't seem to work.

And, the problem with trapping the class name is "what if you have more than one browser control on a form?"

???
0
carpbyte
Asked:
carpbyte
  • 7
  • 4
  • 3
  • +2
1 Solution
 
mdouganCommented:
I always thought that scrollbars were controled by commands in the HTML.  To turn off scrollbars for a frame:

<FRAME frameBorder=no marginHeight=0 marginWidth=0 name=content scrolling=no src="about.html">

Though you might be able to put this up in the Body tag or somewhere else.

You might even be able to wrap the existing HTML or modify the existing HTML to insert this tag by using the innerHTML property:

Debug.Print WebBrowser1.Document.body.innerHTML


0
 
carpbyteAuthor Commented:
Unfortunately at times I'm displaying straight XML, so without doing a translation I can't rely on HTML to control the scrolling.

As for the points, I probably should have put more emphasis on the handle to the WEbBrowser issue. If someone has a way to determine the hwnd regardless of how many "browser controls" are on the form, this would be a good enough solution for me.

So far I seen solutions that iterate through the FindWindow/GetWindow, but this doesn't help if there's more than one control.

Thanks for the response.

0
 
AzraSoundCommented:
Simplest solution...

Place the webBrowser control inside of a picturebox control (or other container control) and position it such that its scrollbars are "hidden" under its container.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
carpbyteAuthor Commented:
An interesting solution, but I'm still looking for the whole "hwnd" end of things because I need to make some screwy API calls that rely on it.

But, this might solve a different issue - if the browser control is in a container (whose hwnd can be accurately determined) is there some way to iterate the hwnds within the container?

My question may be getting a little off base, but the app in question isn't a "WEB" application, but rather uses the WebBrowser because of its inherent support of a lot of default file formats (Word docs, Excel, PDF, etc.)

Thanks for the comment.

Carp.
0
 
AzraSoundCommented:
You may find use out of this sample, then, that subclasses the webbrowser control to trap right-clicks:

http://blackbeltvb.com/index.htm?free/webbmenu.htm
0
 
carpbyteAuthor Commented:
Thanks, but VBBlack Belt is where I started out with the question!

Matt's sample helps, but there's still the issue of determining "which" handle is returned when there are multiple browser controls, or even someone else's app utilizing one.

Thanks for the response.

Carp.
0
 
AzraSoundCommented:
Well, I would attack that by iterating the parent handles of those found using Matt's technique and eventually it should lead back to either the easily attainable WebBrowser.hWnd or to your Form.hWnd.
0
 
Richie_SimonettiIT OperationsCommented:
See www.angelfire.com/realm/vb-shared/index.html under "ie DOM..." topic. (one line of code!)
0
 
carpbyteAuthor Commented:
This does indeed solve the problem!

Unfortunately, it doesn't work with ActiveX documents ("object doesn't support this property...") which is what I'm using.

I'll be happy to award you the points, but I've forgotten how to accept a comment as an answer.

?

Thanks.

Carp.
0
 
AzraSoundCommented:
I thought you were interested in an API solution?

>>An interesting solution, but I'm still looking for the whole "hwnd" end of things because I need to make some screwy API calls that rely on it.
0
 
carpbyteAuthor Commented:
Well I kind of thought there would be something obvious with regard to a SendMessage, but that doesn't appear to be the case.

Richie's comment works for HTML & I may have to port the ActiveX Doc anyway, so....
0
 
Richie_SimonettiIT OperationsCommented:
If i remember well, for Active x documents: if they fit in browser window, scroll bars should not be visible but maybe i am wrong.
0
 
carpbyteAuthor Commented:
Depends on the size of the container. They will go away once the docsize is less than the container.
0
 
Richie_SimonettiIT OperationsCommented:
exactly what i am saying.
0
 
SashiJanahanCommented:
To get the hwnd of indexed Webbrowser objects use the setfocus method of the particular webbrowser control you want the handle for then call the GetFocus API call to return you the webbrowsers handle...

Public Declare Function GetFocus Lib "user32" () As Long

dim hwnd1 as long, hwnd2 as long

webbrowser1(0).setfocus
hwnd1 = getFocus

webbrowser1(1).setfocus
hwnd1 = getFocus

This should work!
0
 
carpbyteAuthor Commented:
I've actually forgotten what I needed to do with this, but your method does get the hwnd which was the major obstacle.

Thanks.

Carp.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now