Solved

Removing scroll bars from WEB Browser

Posted on 2002-06-25
16
176 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now