Solved

Removing scroll bars from WEB Browser

Posted on 2002-06-25
16
178 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 200 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 55
Windows Script Host failed (Access is denied.) error 6 146
Child Form in front 4 47
MS Access 03, TransferText, decimal places 8 69
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

777 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