473,382 Members | 1,329 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,382 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 1511

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: msnews.microsoft.com | 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 =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.