Solved

How do I control WebBrowser attributes (bg color; scroll bars; etc)

Posted on 2001-08-03
10
1,021 Views
Last Modified: 2012-06-27
I am using WebBowser component in shdocvw.dll to display animated gif inside a form.  I would like to simply display the gif, without any scroll bars, borders and have the background color match the form.
If there is another way to display the gif, I'm open for suggestions.

WebBrowser1.Navigate "file.gif"

Thanks,

Russ
0
Comment
Question by:RUSS_EMI
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 6350866
>>without any scroll bars

the most common workaround is to place the webbrowser control inside of another container, and position it such that the scroll bars are hidden, such as a frame or picturebox control.


>>and have the background color match the form

this would require that you edit the gif to have the background color you desire.
0
 
LVL 5

Expert Comment

by:KDivad
ID: 6350951
>>and have the background color match the form

I thought he meant the background color of the webbrowser control? Just in case, here's how to do that easily:

WB.Navigate "about:blank" 'Clear the last document first!
WB.Document.Write "<body bgcolor=#C0C0C0><img src=" & Chr$(34) & "file.gif" & Chr$(34) & ">"
0
 
LVL 5

Expert Comment

by:KDivad
ID: 6350954
As Azra (do you mind "Azra"?) said, you will need to put the WB control inside another container (such as a picbox) and resize it just right to hide the scrollbars and border.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 6351372
<ping>
0
 
LVL 14

Expert Comment

by:wsh2
ID: 6351381
From Vb2TheMax:
-------------------------------------
The standard PictureBox control doesn't support the Animated GIF graphic format. However, you can display these images by using a WebBrowser control:

WebBrowser1.Navigate "c:\Images\Animated.Gif"

The only problem of this technique is that the WebBrowser control also displays a vertical and/or horizontal scroll bar. You can hide these scrollbars, if you wish, simply by putting the WebBrowser control inside a PictureBox control, whose width and height is smaller than the WebBrowser control. The following code snippet does that programmatically via the Add method of the Controls collection (requires VB6):

Private Declare Function GetSystemMetrics Lib "user32" Alias "GetSystemMetrics" _
    (ByVal nIndex As Long) As Long
Private Const SM_CXVSCROLL = 2
Private Const SM_CYHSCROLL = 3

' create a new PictureBox
Dim picBox As PictureBox
Set picBox = Controls.Add("VB.PictureBox", "picBox")

' resize the picture box so that it can hide the
' WebBrowser's scroll bars    
With WebBrowser1
    picBox.Move .Left, .Top, .Width - ScaleX(GetSystemMetrics(SM_CXVSCROLL), _
        vbPixels), .Height - ScaleY(GetSystemMetrics(SM_CYHSCROLL), vbPixels)
    ' move the WebBrowser inside the picture box
    Set WebBrowser1.Container = picBox
    ' ensure that the WebBrowser's border isn't visible
    .Move -ScaleX(2, vbPixels), -ScaleY(2, vbPixels)
End With

' all controls are created invisible
picBox.Visible = True

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:RUSS_EMI
ID: 6351399
As I have variable size animated gifs to display wsh2's answer is most correct, but it doesn't address the background color issue.
I tried using .document.write "<...>" and got a run time error 91.  "Object or With variable block not set".
Please advice.

Thank you,

Russ
0
 

Author Comment

by:RUSS_EMI
ID: 6351452
Ammending my last comment;
I can't seem to center the gif and minimize the area around it. This is in addition to the color question.
Russ
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 6351558
try:

WebBrowser.Navigate "about:blank"
Do While WebBrowser.ReadyState <> READYSTATE_COMPLETE
   DoEvents
Loop
WebBrowser.Document.write strHTML



>>do you mind "Azra"?

either that or "sexy", whichever you prefer...
0
 

Author Comment

by:RUSS_EMI
ID: 6351566
Azra or "Sexy" (as you prefer);
   The more complicated solution of wsh2 didn't work, because of the inability to center and color correctly.
Thank you for your quick response.

Russ
0
 
LVL 5

Expert Comment

by:KDivad
ID: 6352356
I'm afraid I'd need to know a little more about you before I'd use "sexy"! <grin>
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

705 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

20 Experts available now in Live!

Get 1:1 Help Now