Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2001-08-03
10
Medium Priority
?
1,286 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

824 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