?
Solved

Removing scroll bars from WEB Browser

Posted on 2002-06-25
16
Medium Priority
?
201 Views
Last Modified: 2013-12-25
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
Comment
Question by:carpbyte
  • 7
  • 4
  • 3
  • +2
16 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 7111042
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
 

Author Comment

by:carpbyte
ID: 7111137
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 7111838
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:carpbyte
ID: 7111908
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 7113707
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
 

Author Comment

by:carpbyte
ID: 7114281
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 7114677
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7221048
See www.angelfire.com/realm/vb-shared/index.html under "ie DOM..." topic. (one line of code!)
0
 

Author Comment

by:carpbyte
ID: 7221118
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
 
LVL 28

Expert Comment

by:AzraSound
ID: 7221282
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
 

Author Comment

by:carpbyte
ID: 7221402
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7222234
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
 

Author Comment

by:carpbyte
ID: 7222804
Depends on the size of the container. They will go away once the docsize is less than the container.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7222919
exactly what i am saying.
0
 

Accepted Solution

by:
SashiJanahan earned 600 total points
ID: 7481032
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
 

Author Comment

by:carpbyte
ID: 7481115
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 15 hours left to enroll

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question