473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Remove scrollbars from Browser Control

Hello,
I am trying to remove the scrollbars from any page I load up into the
browser control on a window form. I first tried the following:

browserDoc = (mshtml.HTMLDocument)browser.Document;
browserBody = (mshtml.HTMLBody)browserDoc.body;
browserBody.scroll = "no";

This worked for most pages but not all. When I navigated to the following
web site:

http://www.levaquinspeakers.com

It still showed the vertical scroll bar although it was disabled since no
scrolling was needed. On sites like http://www.microsoft.com it worked
perfectly. So I did a little research and found people saying that I should
use SetWindowLong API passing it the compliment of WS_VSCROLL and WS_HSCROLL
to turn off the scrollbars. Here is the code I used:

private const int CONST_GWL_STYLE = -16;
private const int CONST_WS_VSCROLL = 0x00200000;
private const int CONST_WS_HSCROLL = 0x00100000;
private const int CONST_SWP_NOSIZE = 0x0001;
private const int CONST_SWP_NOMOVE = 0x0002;
private const int CONST_SWP_NOZORDER = 0x0004;
private const int CONST_SWP_FRAMECHANGED = 0x0020;
private const int CONST_SET_WINDOW_POS_FLAGS = CONST_SWP_NOMOVE |
CONST_SWP_NOSIZE | CONST_SWP_NOZORDER | CONST_SWP_FRAMECHANGED;

//API Calls.
[ DllImport( "user32.dll", EntryPoint = "GetClientRect" ) ]
private static extern int GetClientRect (IntPtr hWnd, ref Rectangle lpRect);
[ DllImport( "user32.dll", EntryPoint = "GetWindowLong" ) ]
private static extern IntPtr GetWindowLongPtr (IntPtr hWnd, int nIndex);
[ DllImport( "user32.dll", EntryPoint = "SetWindowLong" ) ]
private static extern IntPtr SetWindowLongPtr (IntPtr hWnd, int nIndex,
IntPtr dwNewLong);
[ DllImport( "user32.dll", EntryPoint = "SetWindowPos" ) ]
private static extern int SetWindowPos (IntPtr hWnd, IntPtr hWndInsertAfter,
int X, int Y, int cx, int cy, uint uFlags);

IntPtr windowStyle;
int returnValue;

windowStyle = GetWindowLongPtr(browser.Handle, CONST_GWL_STYLE);
windowStyle = new IntPtr(windowStyle.ToInt32() & ~CONST_WS_VSCROLL &
~CONST_WS_HSCROLL);
windowStyle = SetWindowLongPtr(browser.Handle, CONST_GWL_STYLE,
windowStyle);
returnValue = SetWindowPos(browser.Handle, new IntPtr(0), 0, 0, 0, 0,
CONST_SET_WINDOW_POS_FLAGS);

I tried with and without the SetWindowPos call at the end. When I step
through the code I get a proper windowStyle back but it seems the window
already has the WS_VSCROLL and WS_HSCROLL because doing an AND with there
compliments does not change the style at all.

Is there anyway I can get the browser control to reliably remove the
scrollbars? If not is it possible to determine when either the vertical or
horizontal are displayed along with there widths? Thank you for any help you
can provide!!!
Thanks,
Ken
Nov 17 '05 #1
0 3526

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Nobody | last post by:
Okay, you are all so smart in here. Answer me this: IE6 in standards mode doesn't seem to hide scrollbars on the body element (overflow:hide) Ain't this a quandary. I have it in my head that I...
14
by: Jorg Matter | last post by:
Hello I should like to define the colors of the scrollbars for divs with overflows set to auto. I have a design with black background and white text. Now the scrollbars do not look very nice and...
7
by: Sujan | last post by:
Hello all, Is it possible to remove scrollbar(s) without using frames. Is there any code which could be applied in body tag to remove scrollbar(s). Thanks in adv, Sujan
5
by: jvb | last post by:
I hope this is the correct place to ask this question. If not, would some kind person tell me where I should? In IE, one can use the javascript code, "document.body.scroll='yes/no'" to dynamically...
0
by: Kenneth H. Brannigan | last post by:
Hello, I am trying to remove the scrollbars from any page I load up into the browser control on a window form. I first tried the following: browserDoc = (mshtml.HTMLDocument)browser.Document;...
0
by: Kenneth H. Brannigan | last post by:
Even though I can see that the scroll bars are visible a call to GetScrollBarinfo says they are not visible: private const uint CONST_OBJID_VSCROLL = 0xFFFFFFFB; private const uint...
17
by: Dino M. Buljubasic | last post by:
I have a treeview and a checked list view controls one beside another. I want to make them work so that when I scroll down or up one of them the other does the same. Any help will be...
2
by: Ernst Elzas | last post by:
Hello, If these questions have been asked numerous times before, please excuse me, I have not managed to find the information I needed. I'm making a webpage (for now it will only be in two...
1
by: prashweenet | last post by:
Hi I cannot remove the scrollbars in my application using scrollbars=no My browser is IE 6.0.2900 sp2 help much appricated Code snippet is below var sreturnval =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.